| 1 | set -euo pipefail |
| 2 | |
| 3 | echo "[entrypoint] waiting for postgres..." |
| 4 | until python -c " |
| 5 | import sys, psycopg2, os, urllib.parse as u |
| 6 | dsn = os.environ.get('SIGHTLINE_DATABASE_URL','').replace('postgresql+psycopg2','postgresql') |
| 7 | try: |
| 8 | psycopg2.connect(dsn).close() |
| 9 | except Exception as e: |
| 10 | sys.exit(1) |
| 11 | " 2>/dev/null; do |
| 12 | sleep 1 |
| 13 | done |
| 14 | |
| 15 | echo "[entrypoint] running migrations..." |
| 16 | alembic upgrade head |
| 17 | |
| 18 | if [ "${SIGHTLINE_SEED:-false}" = "true" ]; then |
| 19 | echo "[entrypoint] seeding demo data..." |
| 20 | python seed.py || echo "[entrypoint] seed skipped/failed (non-fatal)" |
| 21 | fi |
| 22 | |
| 23 | echo "[entrypoint] starting api..." |
| 24 | exec uvicorn app.main:app --host 0.0.0.0 --port 8000 |