services:
  api:
    hostname: api
    build:
      context: .
      dockerfile: Dockerfile.api
    environment:
      NODE_ENV: production
      MONGO_URL: mongodb://sigma:supersecret@mongo:27017/sigma?authSource=admin
      POSTGRES_URL: postgres://sigma:supersecret@postgres:5432/sigma
    depends_on:
      - mongo
      - postgres

  nginx:
    build:
      context: .
      dockerfile: Dockerfile.nginx
    volumes:
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    ports:
      - 3000:80
    depends_on:
      - api

  mongo:
    hostname: mongo
    image: mongo:8.2.2-noble
    environment:
      MONGO_INITDB_ROOT_USERNAME: sigma
      MONGO_INITDB_ROOT_PASSWORD: supersecret
      MONGO_INITDB_DATABASE: sigma
    volumes:
      - mongo-data:/data/db

  postgres:
    hostname: postgres
    image: postgres:18.1-alpine
    environment:
      POSTGRES_USER: sigma
      POSTGRES_PASSWORD: supersecret
      POSTGRES_DB: sigma
    volumes:
      - postgres-data:/var/lib/postgresql/data

volumes:
  postgres-data:
  mongo-data:
