version: '3.8'

services:
  prometheus:
    image: prom/prometheus:latest
    container_name: hellotax-prometheus
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      - ./prometheus/rules:/etc/prometheus/rules
      - prometheus-data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
      - '--web.enable-lifecycle'
    ports:
      - "9090:9090"
    networks:
      - apm-network
    restart: unless-stopped

  grafana:
    image: grafana/grafana:latest
    container_name: hellotax-grafana
    volumes:
      - ./grafana/provisioning:/etc/grafana/provisioning
      - ./grafana/dashboards:/var/lib/grafana/dashboards
      - grafana-data:/var/lib/grafana
    environment:
      - GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin}
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin}
      - GF_USERS_ALLOW_SIGN_UP=false
    ports:
      - "3000:3000"
    networks:
      - apm-network
    restart: unless-stopped
    depends_on:
      - prometheus
      - loki
      - tempo

  loki:
    image: grafana/loki:latest
    container_name: hellotax-loki
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - apm-network
    restart: unless-stopped

  tempo:
    image: grafana/tempo:latest
    container_name: hellotax-tempo
    ports:
      - "3200:3200"
      - "4317:4317"
    command: -config.file=/etc/tempo/tempo.yaml
    volumes:
      - ./tempo/tempo.yaml:/etc/tempo/tempo.yaml
      - tempo-data:/var/tempo
    networks:
      - apm-network
    restart: unless-stopped

  promtail:
    image: grafana/promtail:latest
    container_name: hellotax-promtail
    volumes:
      - /var/log:/var/log:ro
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - ./promtail/promtail.yaml:/etc/promtail/config.yaml
      - ./logs:/apm/logs:ro
    command: -config.file=/etc/promtail/config.yaml
    networks:
      - apm-network
    restart: unless-stopped
    depends_on:
      - loki

  node-exporter:
    image: prom/node-exporter:latest
    container_name: hellotax-node-exporter
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    ports:
      - "9100:9100"
    networks:
      - apm-network
    restart: unless-stopped

volumes:
  prometheus-data:
  grafana-data:
  tempo-data:

networks:
  apm-network:
    driver: bridge
