Skip to content

fix: add postgres service to docker-compose and wire backend dependency#25

Merged
Uchechukwu-Ekezie merged 1 commit into
grantFoxin:mainfrom
boys-cyberhub:fix/issue-1-add-postgres-service
Jun 24, 2026
Merged

fix: add postgres service to docker-compose and wire backend dependency#25
Uchechukwu-Ekezie merged 1 commit into
grantFoxin:mainfrom
boys-cyberhub:fix/issue-1-add-postgres-service

Conversation

@boys-cyberhub

Copy link
Copy Markdown
Contributor

Closes #1

What changed

  • Added postgres:15-alpine service to deployment/docker-compose.yml with credentials that match backend/.env.example defaults (user/password/stellar_portfolio)
  • Added a pg_isready healthcheck on the postgres service so the backend waits until the DB is accepting connections before starting
  • Added a redis-cli ping healthcheck to the existing redis service
  • Updated backend depends_on to use condition: service_healthy for both postgres and redis — eliminates the race where the backend process launched before either dependency was ready
  • Added DATABASE_URL to the backend environment pointing at postgres:5432 (the Docker service hostname) instead of localhost
  • Added REDIS_URL to the backend environment (was already set in the monitoring service but missing from backend)
  • Added postgres_data named volume so database state persists across restarts

Why

The backend connects to Postgres on module load and runs migrations at startup. Without a running Postgres service in the Compose stack the backend immediately exited with ECONNREFUSED 127.0.0.1:5432, making the entire Docker deployment path broken.

How to test

cd deployment
cp ../backend/.env.example .env
docker compose up
# All four services start cleanly; backend logs show migrations complete
curl http://localhost:3001/api/health   # 200 OK

@Uchechukwu-Ekezie Uchechukwu-Ekezie merged commit 0a75ac6 into grantFoxin:main Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: PostgreSQL service missing from docker-compose.yml — Docker deployment fails on database connection

2 participants