deploy.sh: run seed_model_pricing.py after container startup

Without this step the model_pricing collection is empty and all LLM
costs are recorded as $0. Seed is idempotent — safe on every deploy.
Also wait for backend container readiness before running migrations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-04-24 18:10:12 +01:00
parent 3e9ccafad2
commit 8c5146022a

View file

@ -68,9 +68,32 @@ fi
# ── Step 4: Rebuild and restart backend + mongo ───────────────────────────────
echo ""
echo "[4/4] Rebuilding and restarting Docker services..."
echo "[4/5] Rebuilding and restarting Docker services..."
docker compose up -d --build
# Wait for backend to be healthy before running migrations
echo "Waiting for backend container to be healthy..."
TRIES=0
until docker compose exec backend python -c "import sys; sys.exit(0)" 2>/dev/null; do
TRIES=$((TRIES + 1))
if [ "$TRIES" -ge 30 ]; then
echo "ERROR: Backend container did not become ready in time."
docker compose logs --tail=30 backend
exit 1
fi
sleep 2
done
echo "✓ Backend container is ready"
# ── Step 5: Run migrations / seed scripts ────────────────────────────────────
echo ""
echo "[5/5] Running migrations..."
# Seed model pricing (idempotent — safe to run on every deploy)
echo " → seed_model_pricing.py"
docker compose exec backend python scripts/seed_model_pricing.py
echo " ✓ Model pricing seeded"
echo ""
echo "Container status:"
docker compose ps