This commit is contained in:
javad committed 2026-09-10 11:34:19 +03:30
commit fa9d154db9
260 files changed
+17643

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
set -e
echo "==> Waiting for PostgreSQL..."
python - <<'PY'
import os
import time
import psycopg
timeout = int(os.getenv("DATABASE_WAIT_TIMEOUT", "60"))
deadline = time.monotonic() + timeout
last_error = None
while time.monotonic() < deadline:
try:
if os.getenv("DATABASE_URL"):
connection = psycopg.connect(os.environ["DATABASE_URL"], connect_timeout=5)
else:
connection = psycopg.connect(
dbname=os.environ["POSTGRES_DB"],
user=os.environ["POSTGRES_USER"],
password=os.environ["POSTGRES_PASSWORD"],
host=os.environ["POSTGRES_HOST"],
port=os.getenv("POSTGRES_PORT", "5432"),
connect_timeout=5,
)
connection.close()
break
except psycopg.OperationalError as exc:
last_error = exc
time.sleep(2)
else:
raise SystemExit(f"PostgreSQL was not ready after {timeout}s: {last_error}")
PY
if [ "${RUN_STARTUP_TASKS:-0}" = "1" ]; then
echo "==> Applying database migrations..."
python manage.py migrate --noinput
echo "==> Bootstrapping required application data..."
python manage.py bootstrap
echo "==> Collecting static files..."
python manage.py collectstatic --noinput
fi
echo "==> Starting: $*"
exec "$@"