mirror of
https://github.com/AppFlowy-IO/AppFlowy-Cloud.git
synced 2025-04-17 18:44:42 -04:00
chore: update run local server script (#1180)
This commit is contained in:
parent
3e59d41c23
commit
10a4b3a03a
4 changed files with 12 additions and 98 deletions
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -eo pipefail
|
||||
|
||||
if ! [ -x "$(command -v psql)" ]; then
|
||||
echo >&2 "Error: `psql` is not installed."
|
||||
echo >&2 "install using brew: brew install libpq."
|
||||
echo >&2 "link to /usr/local/bin: brew link --force libpq ail"
|
||||
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [ -x "$(command -v sqlx)" ]; then
|
||||
echo >&2 "Error: `sqlx` is not installed."
|
||||
echo >&2 "Use:"
|
||||
echo >&2 "cargo install sqlx-cli --no-default-features --features native-tls,postgres"
|
||||
echo >&2 "to install it."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DB_USER="${POSTGRES_USER:=postgres}"
|
||||
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
|
||||
DB_PORT="${POSTGRES_PORT:=5432}"
|
||||
DB_HOST="${POSTGRES_HOST:=localhost}"
|
||||
DB_NAME="${POSTGRES_DB:=appflowy}"
|
||||
|
||||
if [[ -z "${SKIP_DOCKER}" ]]
|
||||
then
|
||||
RUNNING_POSTGRES_CONTAINER=$(docker ps --filter 'name=postgres' --format '{{.ID}}')
|
||||
if [[ -n $RUNNING_POSTGRES_CONTAINER ]]; then
|
||||
echo >&2 "there is a postgres container already running, kill it with"
|
||||
echo >&2 " docker kill ${RUNNING_POSTGRES_CONTAINER}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker build -t postgres_with_pgjwt -f ./docker/Dockerfile_postgres .
|
||||
|
||||
docker run \
|
||||
-e POSTGRES_USER=${DB_USER} \
|
||||
-e POSTGRES_PASSWORD=${DB_PASSWORD} \
|
||||
-e POSTGRES_DB="${DB_NAME}" \
|
||||
-p "${DB_PORT}":5432 \
|
||||
-d \
|
||||
--name "postgres_$(date '+%s')" \
|
||||
postgres:14 -N 1000
|
||||
fi
|
||||
|
||||
|
||||
# Keep pinging Postgres until it's ready to accept commands
|
||||
until PGPASSWORD="${DB_PASSWORD}" psql -h "${DB_HOST}" -U "${DB_USER}" -p "${DB_PORT}" -d "postgres" -c '\q'; do
|
||||
|
||||
>&2 echo "Postgres is still unavailable - sleeping"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
>&2 echo "Postgres is up and running on port ${DB_PORT} - running migrations now!"
|
||||
|
||||
export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
|
||||
sqlx database create
|
||||
sqlx migrate run
|
||||
|
||||
>&2 echo "Postgres has been migrated, ready to go!"
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
cd "$(dirname "$0")"
|
||||
set -e
|
||||
|
||||
git clone https://github.com/supabase/gotrue.git
|
||||
cp gotrue.env.docker gotrue/.env.docker
|
||||
cd gotrue
|
||||
|
||||
make dev &
|
||||
|
||||
while true; do
|
||||
curl localhost:9999/health && break
|
||||
echo "waiting for gotrue to be ready..."
|
||||
sleep 1
|
||||
done
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -eo pipefail
|
||||
|
||||
RUNNING_CONTAINER=$(docker ps --filter 'name=appflowy_redis' --format '{{.ID}}')
|
||||
if [[ -n $RUNNING_CONTAINER ]]; then
|
||||
echo >&2 "there is a redis container already running, kill it with"
|
||||
echo >&2 " docker kill ${RUNNING_CONTAINER}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Launch Redis using Docker
|
||||
docker run \
|
||||
-p "6379:6379" \
|
||||
-d \
|
||||
--name "appflowy_redis_$(date '+%s')" \
|
||||
redis:7
|
||||
|
||||
>&2 echo "Redis is ready to go!"
|
|
@ -9,6 +9,11 @@ DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
|
|||
DB_PORT="${POSTGRES_PORT:=5432}"
|
||||
DB_HOST="${POSTGRES_HOST:=localhost}"
|
||||
|
||||
if [ ! -f .env ]; then
|
||||
echo ".env file not found in the current directory. Try: cp dev.env .env"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Stop and remove any existing containers to avoid conflicts
|
||||
docker compose --file ./docker-compose-dev.yml down
|
||||
|
||||
|
@ -47,13 +52,20 @@ done
|
|||
# To generate the .sqlx files, we need to run the following command
|
||||
# After the .sqlx files are generated, we build in SQLX_OFFLINE=true
|
||||
# where we don't need to connect to the database
|
||||
# for example: SQLX_OFFLINE=true ./script/run_local_server.sh
|
||||
cargo sqlx database create && cargo sqlx migrate run
|
||||
if [[ -z "${SKIP_SQLX_PREPARE+x}" ]]
|
||||
then
|
||||
cargo sqlx prepare --workspace
|
||||
fi
|
||||
|
||||
|
||||
# To skip this step, set SKIP_APPFLOWY_CLOUD=true before running the script, like this:”
|
||||
# SKIP_APPFLOWY_CLOUD=true ./script/run_local_server.sh. By default, this step is not skipped.
|
||||
if [[ -z "${SKIP_APPFLOWY_CLOUD+x}" ]]
|
||||
then
|
||||
cargo run --package xtask
|
||||
fi
|
||||
|
||||
# revert to require signup email verification
|
||||
export GOTRUE_MAILER_AUTOCONFIRM=false
|
||||
|
|
Loading…
Add table
Reference in a new issue