name: buildkit
services:
  buildkit:
    container_name: buildkit-dev
    build:
      context: ../..
    image: moby/buildkit:local
    ports:
      - 127.0.0.1:5000:5000
      - 127.0.0.1:6060:6060
    restart: always
    privileged: true
    environment:
      OTEL_SERVICE_NAME: buildkitd
      OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317
    command:
      - '--save-cache-debug'
    configs:
      - source: buildkit_config
        target: /etc/buildkit/buildkitd.toml
    volumes:
      - buildkit:/var/lib/buildkit
    depends_on:
      - otel-collector

  otel-collector:
    image: otel/opentelemetry-collector-contrib:0.135.0
    restart: always
    configs:
      - source: otelcol_config
        target: /etc/otelcol-contrib/config.yaml

  jaeger:
    image: jaegertracing/all-in-one:latest
    ports:
      - 127.0.0.1:16686:16686
    profiles:
      - tracing

  prometheus:
    image: prom/prometheus:v2.48.1
    configs:
      - source: prometheus_config
        target: /etc/prometheus/prometheus.yml
    volumes:
      - prometheus:/prometheus
    depends_on:
      - buildkit
    profiles:
      - metrics

  grafana:
    image: grafana/grafana-oss:10.2.3
    configs:
      - source: grafana_config
        target: /etc/grafana/grafana.ini
      - source: grafana_datasources_config
        target: /etc/grafana/provisioning/datasources/datasources.yaml
    ports:
      - 127.0.0.1:3000:3000
    volumes:
      - grafana:/var/lib/grafana
    depends_on:
      - prometheus
    profiles:
      - metrics

volumes:
  buildkit:
  prometheus:
  grafana:

configs:
  buildkit_config:
    file: ./buildkitd.toml

  otelcol_config:
    file: ./otelcol.yaml

  prometheus_config:
    file: ./prometheus.yml

  grafana_config:
    file: ./grafana.ini

  grafana_datasources_config:
    file: ./datasources.yaml
