# Docker Compose configuration for {{ lab_name }}
#
# Generated by: madsci new lab --template standard
# Template version: {{ template_version }}
#
# Usage:
#   docker compose up -d          # Start all services
#   docker compose down            # Stop all services
#   docker compose logs -f         # Follow all logs

services:
  # --- Infrastructure ---

  postgres:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: ${POSTGRES_USER:-madsci}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-madsci}
      POSTGRES_DB: ${POSTGRES_DB:-resources}
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U madsci"]
      interval: 5s
      timeout: 5s
      retries: 5

  mongodb:
    image: mongo:7
    ports:
      - "27017:27017"
    volumes:
      - mongo_data:/data/db
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 5s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 5

  # --- MADSci Managers ---

  lab_manager:
    image: madsci-squid:latest
    build:
      context: .
      dockerfile: Dockerfile.squid
    ports:
      - "8000:8000"
    env_file: .env
    depends_on:
      mongodb:
        condition: service_healthy

  event_manager:
    image: madsci-event-manager:latest
    ports:
      - "8001:8001"
    env_file: .env
    depends_on:
      mongodb:
        condition: service_healthy

  experiment_manager:
    image: madsci-experiment-manager:latest
    ports:
      - "8002:8002"
    env_file: .env
    depends_on:
      mongodb:
        condition: service_healthy

  resource_manager:
    image: madsci-resource-manager:latest
    ports:
      - "8003:8003"
    env_file: .env
    depends_on:
      postgres:
        condition: service_healthy

  data_manager:
    image: madsci-data-manager:latest
    ports:
      - "8004:8004"
    env_file: .env
    depends_on:
      mongodb:
        condition: service_healthy

  workcell_manager:
    image: madsci-workcell-manager:latest
    ports:
      - "8005:8005"
    env_file: .env
    depends_on:
      mongodb:
        condition: service_healthy
      redis:
        condition: service_healthy

  location_manager:
    image: madsci-location-manager:latest
    ports:
      - "8006:8006"
    env_file: .env
    depends_on:
      mongodb:
        condition: service_healthy

volumes:
  postgres_data:
  mongo_data:
