#!/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 "$@"