Files
ai-ticket-platform/infra/backend-entrypoint.sh
2026-07-01 14:29:24 +08:00

27 lines
603 B
Bash

#!/bin/sh
set -eu
python - <<'PY'
import os
import socket
import time
host = os.environ.get("POSTGRES_HOST", "postgres")
port = int(os.environ.get("POSTGRES_PORT", "5432"))
deadline = time.time() + int(os.environ.get("POSTGRES_WAIT_TIMEOUT", "60"))
while True:
try:
with socket.create_connection((host, port), timeout=2):
break
except OSError:
if time.time() > deadline:
raise SystemExit(f"Timed out waiting for PostgreSQL at {host}:{port}")
time.sleep(1)
PY
python manage.py migrate --noinput
python manage.py bootstrap_governance
exec "$@"