feat: PostgreSQL health gates app start (E00-S02-T02)
CI / Frozen lockfile install (pull_request) Successful in 47s

This commit is contained in:
implementer
2026-08-28 23:59:45 +00:00
parent 9e2ac55400
commit 59a102bee3
2 changed files with 125 additions and 14 deletions
+20 -4
View File
@@ -1,10 +1,14 @@
# EPPP Docker Compose baseline — [E00-S02-T01]
# EPPP Docker Compose baseline — [E00-S02-T01/T02]
#
# `docker compose up -d` starts both the database (PostgreSQL) and the
# application (@personal-blog/server). Rollback: `docker compose down`.
#
# Explicitly out of scope for T01 (land in later E00-S02 tasks):
# - PostgreSQL health gate (T02)
# PostgreSQL health gate (T02): the `db` service carries a `pg_isready`
# healthcheck and the `app` service depends on it with
# `condition: service_healthy`, so the application does not start until the
# database is accepting connections.
#
# Explicitly out of scope for T01/T02 (land in later E00-S02 tasks):
# - application health endpoint (T03)
# - DB volume persistence (T04)
#
@@ -22,6 +26,15 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-eppp}
ports:
- "${POSTGRES_PORT:-5432}:5432"
# Health gate for the app service (T02): probe the same credentials the db
# service was created with. `$$` defers interpolation to the container, so
# POSTGRES_USER/POSTGRES_DB overrides apply to the probe too.
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s
app:
build:
@@ -31,5 +44,8 @@ services:
DATABASE_URL: postgres://eppp:eppp@db:5432/eppp
ports:
- "${APP_PORT:-3000}:3000"
# T02: start only once the database reports healthy (service_healthy), so
# the application waits for PostgreSQL before starting.
depends_on:
- db
db:
condition: service_healthy