version: "3.9"

services:
  roastery-api:
    image: steepcraft/tea-roastery-api:1.8.2
    container_name: leaf-and-kettle-api
    restart: unless-stopped
    ports:
      - "8080:8080"
    environment:
      APP_ENV: production
      ROASTERY_NAME: "Leaf & Kettle"
      DEFAULT_TIMEZONE: America/New_York
      BATCH_SIZE_LIMIT_KG: "12"
      INVENTORY_LOW_STOCK_THRESHOLD_KG: "4"
      DATABASE_URL: postgres://roastery:${POSTGRES_PASSWORD}@postgres:5432/roastery
      REDIS_URL: redis://redis:6379/0
    depends_on:
      postgres:
        condition: service_healthy
      redis:
        condition: service_started
    volumes:
      - roast_logs:/app/storage/roast-logs
      - label_exports:/app/storage/labels

  batch-worker:
    image: steepcraft/tea-roastery-worker:1.8.2
    container_name: leaf-and-kettle-worker
    restart: unless-stopped
    environment:
      APP_ENV: production
      DATABASE_URL: postgres://roastery:${POSTGRES_PASSWORD}@postgres:5432/roastery
      REDIS_URL: redis://redis:6379/0
      QUEUES: roast_profiles,label_printing,inventory_sync
    depends_on:
      - roastery-api
      - redis

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

  redis:
    image: redis:7-alpine
    container_name: leaf-and-kettle-cache
    restart: unless-stopped
    command: redis-server --appendonly yes
    volumes:
      - redis_data:/data

volumes:
  postgres_data:
  redis_data:
  roast_logs:
  label_exports: