services:
  prometheus:
    image: docker.io/prom/prometheus:latest
    container_name: prometheus
    restart: always
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus_data:/prometheus
    command:
      - "--config.file=/etc/prometheus/prometheus.yml"
      - "--storage.tsdb.path=/prometheus"
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
        reservations:
          memory: 256M
    networks:
      - grafana_network

  grafana:
    image: docker.io/grafana/grafana:latest
    container_name: grafana
    restart: always
    ports:
      - ${GRAFANA_PORT:?}:3000
    volumes:
      - ./grafana:/etc/grafana/provisioning
      - grafana_data:/var/lib/grafana
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_AUTH_DISABLE_LOGIN_FORM=true
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 256M
        reservations:
          memory: 128M
    networks:
      - grafana_network

  node-exporter:
    image: docker.io/prom/node-exporter:latest
    container_name: node-exporter
    restart: always
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    command:
      - "--path.procfs=/host/proc"
      - "--path.rootfs=/rootfs"
      - "--path.sysfs=/host/sys"
      - "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
      - "--collector.systemd"
    deploy:
      resources:
        limits:
          cpus: '0.1'
          memory: 64M
        reservations:
          memory: 32M
    networks:
      - grafana_network

volumes:
  prometheus_data:
  grafana_data:

networks:
  grafana_network:
    name: grafana_network
    driver: bridge
