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:
+1
-1
@@ -1,7 +1,7 @@
|
||||
FROM node:20-bookworm-slim AS base
|
||||
|
||||
# Prisma needs OpenSSL available during install/generate/runtime.
|
||||
RUN apt-get update -y && apt-get install -y openssl && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update -y && apt-get install -y openssl postgresql-client && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install pnpm
|
||||
RUN npm install -g pnpm@9.14.2
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user