name: leaf-and-flame-roastery

services:
  roaster-api:
    image: ghcr.io/leaf-and-flame/roaster-api:1.8.2
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      NODE_ENV: production
      DATABASE_URL: postgres://roaster:${POSTGRES_PASSWORD}@postgres:5432/roastery
      MQTT_BROKER_URL: mqtt://mqtt:1883
      ROASTERY_NAME: Leaf & Flame
      DEFAULT_BATCH_SIZE_GRAMS: "1200"
      MAX_DRUM_TEMP_C: "145"
      ALERT_EMAIL: roasting@leafandflame.example
    depends_on:
      postgres:
        condition: service_healthy
      mqtt:
        condition: service_started
    volumes:
      - roast_profiles:/app/profiles
      - batch_logs:/app/logs
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/health"]
      interval: 30s
      timeout: 5s
      retries: 3

  roast-worker:
    image: ghcr.io/leaf-and-flame/roast-worker:1.8.2
    restart: unless-stopped
    environment:
      DATABASE_URL: postgres://roaster:${POSTGRES_PASSWORD}@postgres:5432/roastery
      MQTT_BROKER_URL: mqtt://mqtt:1883
      SENSOR_POLL_INTERVAL_MS: "1000"
      COOLING_TARGET_C: "38"
    depends_on:
      - roaster-api
      - mqtt
    volumes:
      - batch_logs:/app/logs

  mqtt:
    image: eclipse-mosquitto:2.0
    restart: unless-stopped
    ports:
      - "1883:1883"
    volumes:
      - ./mosquitto.conf:/mosquitto/config/mosquitto.conf:ro
      - mqtt_data:/mosquitto/data

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

volumes:
  postgres_data:
  mqtt_data:
  roast_profiles:
  batch_logs: