services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus-observability
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
    ports:
      - "9090:9090"
    networks:
      - observability

  grafana:
    image: grafana/grafana:latest
    container_name: grafana-observability
    ports:
      - "3000:3000"
    volumes:
      - grafana-data:/var/lib/grafana
      - ./visualisation/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro
      - ./visualisation/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro
      - ./visualisation/grafana/dashboards:/var/lib/grafana/dashboards:ro
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
      - GF_SMTP_ENABLED=true
      - GF_SMTP_HOST=smtp.gmail.com:587
      - GF_SMTP_USER=kimraumilliardaire@gmail.com
      - GF_SMTP_PASSWORD=vmfc xrtt yvvm gylz
      - GF_SMTP_FROM_ADDRESS=kimraumilliardaire@gmail.com
      - GF_SMTP_FROM_NAME=Grafana Alerts
      - GF_SMTP_SKIP_VERIFY=true
    networks:
      - observability
    depends_on:
      - loki

  loki:
    image: grafana/loki:2.8.2
    container_name: loki-observability
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/local-config.yaml
    user: "1000:1000"
    volumes:
      - ./loki-config.yaml:/etc/loki/local-config.yaml:ro
      - ./loki-wal:/loki/wal
      - ./loki-chunks:/loki/chunks
      - ./loki-index:/loki/index
      - ./loki-compactor:/loki/compactor
    networks:
      - observability

  promtail:
    image: grafana/promtail:2.8.2
    container_name: promtail-observability
    volumes:
      - ./promtail-config.yaml:/etc/promtail/config.yaml
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - /var/log:/var/log:ro
    command:
      - -config.file=/etc/promtail/config.yaml
    networks:
      - observability

  node_exporter:
    image: prom/node-exporter:latest
    container_name: node-exporter
    restart: unless-stopped
    pid: "host"
    network_mode: "host"
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - '--path.procfs=/host/proc'
      - '--path.sysfs=/host/sys'
      - '--collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'    

volumes:
  grafana-data:

networks:
  observability:
    driver: bridge
