version: "2.4"

services:
  query-service:
    hostname: query-service
    build:
      context: "../../../pkg/query-service"
      dockerfile: "./Dockerfile"
      args:
        LDFLAGS: ""
        TARGETPLATFORM: "${LOCAL_GOOS}/${LOCAL_GOARCH}"
    container_name: query-service
    environment:
      - ClickHouseUrl=tcp://clickhouse:9000
      - ALERTMANAGER_API_PREFIX=http://alertmanager:9093/api/
      - SIGNOZ_LOCAL_DB_PATH=/var/lib/signoz/signoz.db
      - DASHBOARDS_PATH=/root/config/dashboards
      - STORAGE=clickhouse
      - GODEBUG=netdns=go
      - TELEMETRY_ENABLED=true
    volumes:
      - ./prometheus.yml:/root/config/prometheus.yml
      - ../dashboards:/root/config/dashboards
      - ./data/signoz/:/var/lib/signoz/
    command: ["-config=/root/config/prometheus.yml"]
    ports:
      - "6060:6060"
      - "8080:8080"
    restart: on-failure
    healthcheck:
      test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/health"]
      interval: 30s
      timeout: 5s
      retries: 3
    depends_on:
      clickhouse:
        condition: service_healthy

  frontend:
    build:
      context: "../../../frontend"
      dockerfile: "./Dockerfile"
      args:
        TARGETOS: "${LOCAL_GOOS}"
        TARGETPLATFORM: "${LOCAL_GOARCH}"
    container_name: frontend
    environment:
      - FRONTEND_API_ENDPOINT=http://query-service:8080
    restart: on-failure
    depends_on:
      - alertmanager
      - query-service
    ports:
      - "3301:3301"
    volumes:
      - ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf
