services:
  # Service 1: The AI Brain (Ollama)
  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    ports:
      - "127.0.0.1:11434:11434"
    volumes:
      - ollama_data:/root/.ollama
    restart: always
    # NEW: The Health Check
    healthcheck:
      # Change this line to use the internal ollama command
      test: ["CMD", "ollama", "list"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 10s

  # Service 2: Your Python Game
  game:
    build: .
    container_name: agent-breaker
    ports:
      - "8000:8000"
      - "8001:8001"
    environment:
      - OLLAMA_HOST=http://ollama:11434
      - PYTHONUNBUFFERED=1
    depends_on:
      ollama:
        condition: service_healthy
    restart: always

volumes:
  ollama_data:
