services:
  grafana:
    image: grafana/grafana:latest
    container_name: grafana
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
    ports:
      - "3002:3000"
    volumes:
      - grafana-data:/var/lib/grafana
    depends_on:
      - loki
    networks:
      - observability-net
    restart: unless-stopped

  loki:
    image: grafana/loki:2.9.0
    container_name: loki
    user: "0"
    command: -config.file=/etc/loki/loki-config.yml
    volumes:
      - ./loki-config.yml:/etc/loki/loki-config.yml:ro
      - loki-data:/loki
    ports:
      - "3100:3100"
    networks:
      - observability-net
    restart: unless-stopped

  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    user: "0"
    volumes:
      - ./prometheus-config.yaml:/etc/prometheus/prometheus-config.yaml
      - /var/run/docker.sock:/var/run/docker.sock:ro
    command: --config.file=/etc/prometheus/prometheus-config.yaml
    ports:
      - "9092:9090"
    networks:
      - observability-net
    restart: unless-stopped

  promtail:
    image: grafana/promtail:2.9.0
    container_name: promtail
    user: "0"
    command: -config.file=/etc/promtail/promtail-config.yml
    volumes:
      - ./promtail-config.yml:/etc/promtail/promtail-config.yml:ro
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    depends_on:
      - loki
    networks:
      - observability-net
    restart: unless-stopped

volumes:
  grafana-data:
  loki-data:

networks:
  observability-net:
    driver: bridge