feat: reinforce one liner experience (#4688)

* feat: add more dependencies check, randomize postgres admin password, tail logs of server container

* feat: improve retro compatibility

* feat: comment POSTGRES_ADMIN_PASSWORD as it will be generated by the one liner
This commit is contained in:
Quentin G
2024-03-29 15:25:41 +01:00
committed by GitHub
parent 743e203bc7
commit 35fb77d9a8
3 changed files with 23 additions and 4 deletions

View File

@@ -20,6 +20,18 @@ if ! command -v curl &>/dev/null; then
exit 1
fi
# Check if docker compose version is >= 2
if [ "$(docker compose version --short | cut -d' ' -f3 | cut -d'.' -f1)" -lt 2 ]; then
echo -e "\t❌ Docker Compose is outdated. Please update Docker Compose to version 2 or higher.\n\t\tSee https://docs.docker.com/compose/install/linux/"
exit 1
fi
# Check if docker-compose is installed, if so issue a warning if version is < 2
if command -v docker-compose &>/dev/null; then
if [ "$(docker-compose version --short | cut -d' ' -f3 | cut -d'.' -f1)" -lt 2 ]; then
echo -e "\n\t⚠ 'docker-compose' is installed but outdated. Make sure to use 'docker compose' or to upgrade 'docker-compose' to version 2.\n\t\tSee https://docs.docker.com/compose/install/standalone/\n"
fi
fi
# Catch errors
set -e
function on_exit {
@@ -78,10 +90,13 @@ else
fi
# Generate random strings for secrets
echo "# === Randomly generated secrets ===" >>.env
echo "ACCESS_TOKEN_SECRET=$(openssl rand -base64 32)" >>.env
echo "LOGIN_TOKEN_SECRET=$(openssl rand -base64 32)" >>.env
echo "REFRESH_TOKEN_SECRET=$(openssl rand -base64 32)" >>.env
echo "FILE_TOKEN_SECRET=$(openssl rand -base64 32)" >>.env
echo "" >>.env
echo "POSTGRES_ADMIN_PASSWORD=$(openssl rand -base64 32)" >>.env
echo -e "\t• .env configuration completed"
@@ -113,11 +128,14 @@ else
echo "🐳 Starting Docker containers..."
docker compose up -d
# Check if port is listening
echo -n "Waiting for server to be healthy..."
echo "Waiting for server to be healthy, it might take a few minutes while we initialize the database..."
# Tail logs of the server until it's ready
docker compose logs -f server &
pid=$!
while [ ! $(docker inspect --format='{{.State.Health.Status}}' twenty-server-1) = "healthy" ]; do
echo -n "."
sleep 1
done
kill $pid
echo ""
echo "✅ Server is up and running"
fi

View File

@@ -1,6 +1,6 @@
TAG=latest
POSTGRES_ADMIN_PASSWORD=replace_me_with_a_strong_password
# POSTGRES_ADMIN_PASSWORD=replace_me_with_a_strong_password
PG_DATABASE_HOST=db:5432

View File

@@ -1,3 +1,4 @@
version: "3.9"
name: twenty
services:
@@ -13,7 +14,7 @@ services:
SERVER_URL: ${SERVER_URL}
FRONT_BASE_URL: ${FRONT_BASE_URL:-$SERVER_URL}
ENABLE_DB_MIGRATIONS: true
ENABLE_DB_MIGRATIONS: "true"
SIGN_IN_PREFILLED: ${SIGN_IN_PREFILLED}
STORAGE_TYPE: ${STORAGE_TYPE}