<mohammadrony>
# https://github.com/grafana/tempo/blob/main/example/docker-compose/otel-collector/docker-compose.yaml
services:
  # Tempo runs as user 10001, and docker compose creates the volume as root.
  # As such, we need to chown the volume in order for Tempo to start correctly.
  init:
    image: &tempoImage grafana/tempo:latest
    container_name: init
    user: root
    entrypoint:
      - "chown"
      - "10001:10001"
      - "/var/tempo"
    volumes:
      - tempo-data:/var/tempo
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: '1024M'
        reservations:
          cpus: '0.5'
          memory: '512M'
    networks:
      - monitoring

  tempo:
    image: *tempoImage
    container_name: tempo
    command: [ "-config.file=/etc/tempo.yaml" ]
    volumes:
      - ./tempo.yaml:/etc/tempo.yaml
      - tempo-data:/var/tempo
    ports:
      # - "14268"  # jaeger ingest
      - "3200:3200"   # tempo
      - "4317:4317"  # otlp grpc
      - "4318:4318"  # otlp http
      # - "9411"   # zipkin
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: '1024M'
        reservations:
          cpus: '0.5'
          memory: '512M'
    depends_on:
      - init
    networks:
      - monitoring

  # And put them in an OTEL collector pipeline...
  otel-collector:
    image: otel/opentelemetry-collector:0.86.0
    # image: otel/opentelemetry-collector-contrib:0.104.0
    container_name: otel-collector
    ports:
      - "4317:4317"
      - "4318:4318"
    command: [ "--config=/etc/otel-collector.yaml" ]
    volumes:
      - ./otel-collector.yaml:/etc/otel-collector.yaml
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: '1024M'
        reservations:
          cpus: '0.5'
          memory: '512M'
    networks:
      - monitoring

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    restart: unless-stopped
    # ports:
    #   - "9090:9090"
    volumes:
      - ./prometheus.yaml:/etc/prometheus/prometheus.yaml
      - prometheus-data:/prometheus
    command:
      - --config.file=/etc/prometheus/prometheus.yaml
      - --storage.tsdb.path=/prometheus
      - --web.console.libraries=/etc/prometheus/console_libraries
      - --web.console.templates=/etc/prometheus/consoles
      - --web.enable-remote-write-receiver
      - --enable-feature=exemplar-storage
      - --enable-feature=native-histograms
      - --web.enable-lifecycle
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: '1G'
        reservations:
          cpus: '0.25'
          memory: '512M'
    networks:
      - monitoring

  grafana:
    image: grafana/grafana-enterprise:latest
    container_name: grafana
    volumes:
      - ./grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
      - grafana-data:/var/lib/grafana
    # environment:
    #   - GF_AUTH_ANONYMOUS_ENABLED=true
    #   - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
    #   - GF_AUTH_DISABLE_LOGIN_FORM=true
    #   - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor
    deploy:
      resources:
        limits:
          cpus: '1'
          memory: '1024M'
        reservations:
          cpus: '0.5'
          memory: '512M'
    ports:
      - "3000:3000"
    networks:
      - monitoring

volumes:
  tempo-data:
  grafana-data:

networks:
  monitoring:
    name: monitoring
    driver: bridge