fix(infra): wait for postgres readiness before running migrations on container start

Installs postgresql-client in the dev image so pg_isready is available.
The startup script now polls until postgres accepts connections, preventing
the P1001 "can't reach database" crash when the app container starts before
postgres is fully ready.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 21:14:31 +02:00
parent 43de66e982
commit c784b4b378
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -1,6 +1,13 @@
#!/bin/sh
set -eu
# Wait for postgres to be ready before running migrations
echo "Waiting for postgres..."
until pg_isready -h "${POSTGRES_HOST:-postgres}" -p "${POSTGRES_PORT:-5432}" -q; do
sleep 1
done
echo "Postgres is ready."
# Regenerate Prisma client (needed after bind-mount overlays the image layer)
pnpm --filter @capakraken/db db:generate