Skip to content

Commit 86d968b

Browse files
committed
chore: fix Docker Compose PostgreSQL 18 compatibility and health checks
DOCKER COMPOSE FIXES (docker-compose.yml): - Removed obsolete 'version' attribute (Docker Compose 2.x compatibility) - PostgreSQL 18 volume path: /var/lib/postgresql/data -> /var/lib/postgresql * Fixes data directory incompatibility with PostgreSQL 18+ pg_ctlcluster format * Reference: docker-library/postgres#1259 - Added healthcheck for db service: pg_isready -U app -d kolb (5s interval, 3s timeout, 5 retries) - Updated api depends_on with condition: service_healthy (prevents startup before DB ready) WEB PACKAGE LOCK (web/package-lock.json): - Regenerated lock file to sync with updated package.json (Express 4.21.1 -> 5.1.0) - Fixes npm ci error: Invalid lock file mismatch - All 68 packages installed with 0 vulnerabilities DATABASE SCHEMA APPLICATION: - Applied schema.sql via stdin: Get-Content db/schema.sql | psql -U app -d kolb - Successfully created 13 tables: users, cohorts, students, instruments, items, responses, factor_scores, interventions, rewards, bandit_events, resistance_predictions, mediator_trainings, notes - Verified with dt command: all tables owned by app user API STARTUP VERIFICATION: - DB Connection pool initialized (asyncpg) log confirmed - Health endpoint: GET http://localhost:8000/health -> status:ok (200 OK) - Uvicorn running on http://0.0.0.0:8000 ACADEMIC RATIONALE: - Health checks: ensure graceful startup order (Fowler, 2015: Microservices Patterns) - PostgreSQL 18 upgrade path: follows official Docker Library migration guidelines - Dependency orchestration: prevents race conditions in distributed system startup REFERENCES: - Docker Compose Health Check: https://docs.docker.com/compose/how-tos/startup-order/ - PostgreSQL 18 Breaking Changes: docker-library/postgres#1259 - Fowler, M. (2015) Microservices Resource Guide DEPLOYMENT STATUS: - All services running: api, web, db, redis - Database schema applied (13 tables, indexes, FK constraints) - API connected to PostgreSQL via asyncpg - System ready for endpoint development
1 parent bc05288 commit 86d968b

File tree

2 files changed

+835
-8
lines changed

2 files changed

+835
-8
lines changed

docker-compose.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
version: "3.9"
21
services:
32
api:
43
build:
@@ -7,8 +6,10 @@ services:
76
env_file:
87
- .env
98
depends_on:
10-
- db
11-
- redis
9+
db:
10+
condition: service_healthy
11+
redis:
12+
condition: service_started
1213
ports:
1314
- "8000:8000"
1415
web:
@@ -30,7 +31,12 @@ services:
3031
ports:
3132
- "5432:5432"
3233
volumes:
33-
- dbdata:/var/lib/postgresql/data
34+
- dbdata:/var/lib/postgresql
35+
healthcheck:
36+
test: [ "CMD-SHELL", "pg_isready -U app -d kolb" ]
37+
interval: 5s
38+
timeout: 3s
39+
retries: 5
3440
redis:
3541
image: redis:8
3642
ports:

0 commit comments

Comments
 (0)