Fix API deploy healthcheck by starting Kestrel before migrate/seed.
CI / backend (push) Canceled after 0s
CI / frontend (push) Canceled after 0s

Compose was marking the API unhealthy because bootstrap blocked app.Run(), so /health/live never answered within the HEALTHCHECK window.
This commit is contained in:
2026-10-04 19:27:21 +08:00
parent d013dd4bb5
commit 7d7332641f
9 changed files with 915 additions and 22 deletions
+11 -4
View File
@@ -73,9 +73,10 @@ jobs:
# Postgres lives on the deploy host's shared-services network and is not
# reachable from act_runner, so the bundle is copied there and executed in
# a one-shot container joined to that network (Host=postgres resolves).
# NOTE: Program.cs also runs db.Database.MigrateAsync() on API startup, so
# this job is a defense-in-depth pre-deploy step using a DDL-privileged
# credential the API container never sees, not the only migration path.
# NOTE: AppBootstrapHostedService also runs db.Database.MigrateAsync() after
# Kestrel listens, so this job is a defense-in-depth pre-deploy step using a
# DDL-privileged credential the API container never sees, not the only
# migration path.
steps:
- uses: actions/checkout@v4
@@ -162,7 +163,13 @@ jobs:
fi
docker compose -f docker-compose.prod.yml --env-file .env pull
docker compose -f docker-compose.prod.yml --env-file .env up -d --remove-orphans
if ! docker compose -f docker-compose.prod.yml --env-file .env up -d --remove-orphans; then
echo "Compose up failed — dumping API status/logs:"
docker inspect --format 'status={{.State.Status}} health={{if .State.Health}}{{.State.Health.Status}}{{else}}none{{end}}' \
vigilcare_records_api || true
docker compose -f docker-compose.prod.yml --env-file .env logs --tail 100 api || true
exit 1
fi
docker image prune -f
EOF