services:
  prometheus:
    image: prom/prometheus:v2.52.0
    user: "0:0"
    network_mode: host
    command:
      - --config.file=/etc/prometheus/prometheus.yml
      - --storage.tsdb.path=/prometheus
      - --web.enable-lifecycle
      - --web.listen-address=0.0.0.0:${DEV_PROM_E2E_PROMETHEUS_PORT:-19190}
    volumes:
      - ./generated/compose/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - ./generated/compose/prometheus-data:/prometheus
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:${DEV_PROM_E2E_PROMETHEUS_PORT:-19190}/-/healthy"]
      interval: 5s
      timeout: 3s
      retries: 20

  grafana:
    image: grafana/grafana:10.4.0
    network_mode: host
    environment:
      GF_SECURITY_ADMIN_USER: "${DEV_PROM_E2E_GRAFANA_ADMIN_USER:-admin}"
      GF_SECURITY_ADMIN_PASSWORD: "${DEV_PROM_E2E_GRAFANA_ADMIN_PASSWORD:-admin}"
      GF_USERS_ALLOW_SIGN_UP: "false"
      GF_SERVER_HTTP_PORT: "${DEV_PROM_E2E_GRAFANA_PORT:-13100}"
    volumes:
      - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
      - ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
      - ../prom-e2e/dashboard:/var/lib/grafana/dashboards:ro
    depends_on:
      prometheus:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://127.0.0.1:${DEV_PROM_E2E_GRAFANA_PORT:-13100}/api/health"]
      interval: 5s
      timeout: 3s
      retries: 20
