fix: replace hardcoded DB credentials with env var interpolation in docker-compose.yml

All DATABASE_URL values and postgres service env vars now use
\${POSTGRES_USER}, \${POSTGRES_PASSWORD}, \${POSTGRES_DB} interpolation
instead of hardcoded ml_user/ml_password/candle_annotator values.
Also updated pg_isready healthcheck to use the same env vars.

Closes task 1.5.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marko Djordjevic 2026-02-18 10:57:31 +01:00
parent 9bc82b822c
commit e3469ec39f
2 changed files with 7 additions and 7 deletions

View file

@ -7,7 +7,7 @@ services:
- ml-data:/app/ml-data
environment:
- NODE_ENV=production
- DATABASE_URL=postgresql://ml_user:ml_password@postgres:5432/candle_annotator
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
- INFERENCE_API_URL=http://ml-service:8001
- INFERENCE_API_TIMEOUT=30000
- INFERENCE_BATCH_TIMEOUT=120000
@ -34,7 +34,7 @@ services:
- mlflow-data:/app/mlruns
environment:
- MLFLOW_TRACKING_URI=http://mlflow:5000
- DATABASE_URL=postgresql://ml_user:ml_password@postgres:5432/candle_annotator
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
- PYTHONUNBUFFERED=1
restart: unless-stopped
depends_on:
@ -70,12 +70,12 @@ services:
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
- POSTGRES_USER=ml_user
- POSTGRES_PASSWORD=ml_password
- POSTGRES_DB=candle_annotator
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ml_user -d candle_annotator"]
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5

View file

@ -4,7 +4,7 @@
- [x] 1.2 `[haiku]` Add `models/` and `*.pkl` to `.gitignore`
- [x] 1.3 `[haiku]` Replace real credentials in `.env.example` with placeholders (`POSTGRES_PASSWORD=change_me_to_a_strong_password`)
- [x] 1.4 `[haiku]` Remove SQL comment with credentials from `services/ml/app/db.py` and add fail-fast check for missing `DATABASE_URL`
- [ ] 1.5 `[sonnet]` Update `docker-compose.yml` to use `${POSTGRES_USER}`, `${POSTGRES_PASSWORD}`, `${POSTGRES_DB}` env var interpolation in all DATABASE_URL values
- [x] 1.5 `[sonnet]` Update `docker-compose.yml` to use `${POSTGRES_USER}`, `${POSTGRES_PASSWORD}`, `${POSTGRES_DB}` env var interpolation in all DATABASE_URL values
- [ ] 1.6 `[haiku]` Bind PostgreSQL port to `127.0.0.1:5432:5432` in `docker-compose.yml`
- [ ] 1.7 `[haiku]` Bind MLflow port to `127.0.0.1:5000:5000` in `docker-compose.yml`
- [ ] 1.8 `[haiku]` Bind ML service port to `127.0.0.1:8001:8001` in `docker-compose.yml`