feat: PostgreSQL health gates app start (E00-S02-T02)
CI / Frozen lockfile install (pull_request) Successful in 47s
CI / Frozen lockfile install (pull_request) Successful in 47s
This commit is contained in:
+20
-4
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user