Skip to content

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

Description

@Uchechukwu-Ekezie

Description

The deployment/docker-compose.yml defines four services (frontend, backend, redis, monitoring) but omits a PostgreSQL service. The backend requires a Postgres connection at startup — it connects on boot, runs migrations, and will crash if the database is unreachable.

Steps to Reproduce

git clone https://github.com/grantFoxin/SentientFi
cd SentientFi/deployment
cp ../backend/.env.example .env
docker compose up

Expected: All services start, migrations run, backend reports healthy.
Actual: Backend exits immediately with:

Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect

Root Cause

deployment/docker-compose.yml has no postgres service. The backend's DATABASE_URL in .env.example points to postgresql://portfolio_user:portfolio_pass@localhost:5432/stellar_portfolio but nothing starts that database.

The Redis service is correctly defined, proving the pattern works — it's just missing for Postgres.

Evidence

backend/.env.example line 14:

DATABASE_URL=postgresql://portfolio_user:portfolio_pass@localhost:5432/stellar_portfolio

backend/src/db/client.ts — connects on module load, throws if unreachable.

backend/src/db/migrate.ts — runs on startup, requires live Postgres.

deployment/docker-compose.yml services defined: frontend, backend, redis, monitoringno postgres.

Proposed Fix

Add a postgres service to deployment/docker-compose.yml and make backend depend on it:

services:
  postgres:
    image: postgres:15-alpine
    container_name: portfolio-postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER: portfolio_user
      POSTGRES_PASSWORD: portfolio_pass
      POSTGRES_DB: stellar_portfolio
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U portfolio_user -d stellar_portfolio"]
      interval: 10s
      timeout: 5s
      retries: 5

  backend:
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    # ... rest of backend config

volumes:
  postgres_data:

Also update backend service's environment section to reference the container hostname (postgres) instead of localhost.

Impact

Severity: Critical — The advertised Docker deployment path is completely broken. Any developer following the README's "Docker Deployment" section will hit this error. No workaround without manually starting a Postgres instance.

Environment

  • Docker version: 24+
  • docker compose version: v2
  • File: deployment/docker-compose.yml

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions