#!/bin/sh set -e BAKED_DB="/app/tracker.sqlite" LIVE_DB="${LIVE_DB:-/data/tracker.sqlite}" mkdir -p "$(dirname "$LIVE_DB")" if [ ! -f "$LIVE_DB" ]; then echo "[entrypoint] First boot: seeding $LIVE_DB from $BAKED_DB" cp "$BAKED_DB" "$LIVE_DB" else echo "[entrypoint] Merging $BAKED_DB -> $LIVE_DB (preserves status / next_action)" uv run python /app/scripts/publish_data.py "$BAKED_DB" "$LIVE_DB" fi # Ensure any tables the baked snapshot is missing exist. create_all() is # idempotent and only fills in gaps — alembic stays the local source of # truth for schema evolution; we rebuild the baked DB locally and let it # carry the canonical schema. This guards against deploying a code change # (e.g. a new ORM model) before the baked seed is regenerated. echo "[entrypoint] Ensuring schema with create_all" cd /app && uv run python -c "from opportunity_tracker.db import create_all; create_all()" # Provision dashboard users from SEED_USERS (idempotent — only inserts missing # usernames). echo "[entrypoint] Seeding users" uv run python /app/scripts/seed_users.py exec "$@"