services:
  ha-diag-agent:
    build: .
    container_name: ha-diag-agent
    restart: unless-stopped

    env_file:
      - /opt/homelab/config/ha-diag-agent/.env

    volumes:
      # Events dir: host path includes node name; inside container always /events
      - /opt/homelab/events/${NODE_NAME:-ha-diag}:/events
      # SQLite baseline cache and check history
      - /var/lib/ha-diag-agent:/data
      # Optional YAML config (read-only)
      - /opt/homelab/config/ha-diag-agent:/config:ro

    healthcheck:
      test:
        - "CMD"
        - "python"
        - "-c"
        - "import urllib.request; urllib.request.urlopen('http://localhost:8087/health', timeout=5)"
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 20s
