version: '3.8'

services:
  loki:
    image: grafana/loki:latest
    container_name: loki
    restart: unless-stopped
    ports:
      - "127.0.0.1:3100:3100"
    command: -config.file=/etc/loki/local-config.yaml
    volumes:
      - loki-data:/loki
      - ./loki-config.yaml:/etc/loki/local-config.yaml
    networks:
      - monitoring_monitoring
      - traefik-public
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.loki.rule=Host(`loki.ai-impress.com`)"
      - "traefik.http.routers.loki.entrypoints=websecure"
      - "traefik.http.routers.loki.tls.certresolver=cloudflare"
      - "traefik.http.routers.loki.middlewares=authentik@file"
      - "traefik.http.services.loki.loadbalancer.server.port=3100"

  promtail:
    image: grafana/promtail:latest
    container_name: promtail
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - /opt:/opt:ro
      - ./promtail-config.yaml:/etc/promtail/config.yaml
    command: -config.file=/etc/promtail/config.yaml
    networks:
      - monitoring_monitoring

volumes:
  loki-data:

networks:
  monitoring_monitoring:
    external: true
  traefik-public:
    external: true
