#!/usr/bin/env bash # Docker entrypoint for CrowdSight production image. # # Runs database migrations to head BEFORE starting any service, so that the # backend (gunicorn) and the durable worker never query tables that do not # exist yet (fixes worker crash-loop: "no such table: jobs"). # # - Require DATABASE_URL to be set (fail fast with a clear message). # - Run `alembic upgrade head` (idempotent; no-ops when already at head). # - Then exec supervisord to run nginx + backend + worker. set -euo pipefail cd /app/backend if [[ -z "${DATABASE_URL:-}" ]]; then echo "[entrypoint] FATAL: DATABASE_URL is not set. Refusing to start." >&2 exit 1 fi echo "[entrypoint] Running database migrations (alembic upgrade head)..." uv run alembic upgrade head echo "[entrypoint] Migrations complete." echo "[entrypoint] Starting supervisord (nginx + backend + worker)..." exec /usr/bin/supervisord -n