# docker-compose.prod.yml -- Production environment override
# Usage: docker compose -f docker-compose.yml -f docker-compose.prod.yml --env-file .env.prod up -d

services:
  api:
    build:
      context: .
      dockerfile: infrastructure/docker/Dockerfile.api
    container_name: tod_api
    env_file: .env.prod
    environment:
      ENVIRONMENT: production
      LOG_LEVEL: info
      GUNICORN_WORKERS: "2"
    command: ["gunicorn", "app.main:app", "--config", "gunicorn.conf.py"]
    volumes:
      - ./docker-data/git-store:/data/git-store
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
      nats:
        condition: service_healthy
    deploy:
      resources:
        limits:
          memory: 512M
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
    networks:
      - tod

  poller:
    build:
      context: ./poller
      dockerfile: ./Dockerfile
    container_name: tod_poller
    env_file: .env.prod
    environment:
      ENVIRONMENT: production
      LOG_LEVEL: info
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_healthy
      nats:
        condition: service_healthy
    deploy:
      resources:
        limits:
          memory: 256M
    restart: unless-stopped
    logging:
      driver: json-file
      options:
        max-size: "10m"
        max-file: "3"
    networks:
      - tod

  frontend:
    build:
      context: .
      dockerfile: infrastructure/docker/Dockerfile.frontend
    container_name: tod_frontend
    ports:
      - "80:80"
    depends_on:
      - api
    deploy:
      resources:
        limits:
          memory: 64M
    restart: unless-stopped
    networks:
      - tod
