version: "3.9"

services:
  roast-scheduler:
    image: leafandember/roast-scheduler:1.8.2
    container_name: roast-scheduler
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      TZ: America/Toronto
      DATABASE_URL: postgres://tea_roaster:${POSTGRES_PASSWORD}@postgres:5432/tea_roaster
      ROAST_BATCH_MAX_KG: "12"
      DEFAULT_COOLING_MINUTES: "18"
      ALERT_EMAIL: ops@leafandember.example
    depends_on:
      postgres:
        condition: service_healthy
    volumes:
      - roast_logs:/var/log/roasts
      - ./config/roast-profiles.yml:/app/config/roast-profiles.yml:ro
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 5s
      retries: 3

  postgres:
    image: postgres:16-alpine
    container_name: tea-roaster-db
    restart: unless-stopped
    environment:
      POSTGRES_DB: tea_roaster
      POSTGRES_USER: tea_roaster
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
      - ./backups:/backups
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U tea_roaster -d tea_roaster"]
      interval: 10s
      timeout: 5s
      retries: 5

  inventory-worker:
    image: leafandember/inventory-worker:1.8.2
    container_name: tea-inventory-worker
    restart: unless-stopped
    environment:
      APP_ENV: production
      DATABASE_URL: postgres://tea_roaster:${POSTGRES_PASSWORD}@postgres:5432/tea_roaster
      LOW_STOCK_THRESHOLD_KG: "4"
      SUPPLIER_SYNC_CRON: "0 6 * * 1-5"
    depends_on:
      postgres:
        condition: service_healthy

volumes:
  postgres_data:
  roast_logs:

networks:
  default:
    name: tea-roastery-network