services:
  db:
    image: postgres:15-alpine
    container_name: cbt_db
    restart: unless-stopped
    environment:
      POSTGRES_USER: cbt_admin
      POSTGRES_PASSWORD: cbt_password
      POSTGRES_DB: atapoly_cbt
    volumes:
      - cbt_db_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U cbt_admin -d atapoly_cbt"]
      interval: 5s
      timeout: 5s
      retries: 10
    # No host port published — DB is reachable only from the app container.

  app:
    image: atapoly-cbt-app:latest
    build: .
    container_name: cbt_app
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "3001:3001"
    environment:
        PGHOST: db
        PGPORT: 5432
        PGDATABASE: atapoly_cbt
        PGUSER: cbt_admin
        PGPASSWORD: cbt_password
        PORT: 3001
        NODE_ENV: production
        ONLINE_SERVER_URL: https://atapolycbt.atapolysdc.org.ng
        SYNC_TOKEN: 3d56f4d53bb6f93257d039d9a21bfc05c558685a9e3bef8275bd4bc58db5f478fd7e41c71636cc53faa1dd70e1fc3030
        SYNC_INTERVAL: 1800000
        LICENSE_VALIDATE_URL: https://atapolycbt.atapolysdc.org.ng/api/license/validate
        JWT_SECRET: e9171b517733163a90962376a81d5a761150d0f305db6c62b5aef3a56d32a2f986ca9215c7a8f0159551b6120db91bd3

volumes:
  cbt_db_data:
 
