# Loki Stack — Smart City Digital Twin Martinique
# Usage: docker compose -f docker-compose.yml -f docker-compose.loki.yml up -d
# Uses default Loki config (local-config.yaml inside image)

networks:
  smartcity-shared:
    external: true
  traefik-public:
    external: true

volumes:
  loki_data:
    external: false
    name: smart-city_loki_data
  promtail_data:
    external: false
    name: smart-city_promtail_data

services:
  # Loki — Log storage and query engine (default config)
  loki:
    image: grafana/loki:latest
    container_name: smart-city-loki
    networks:
      - smartcity-shared
      - traefik-public
    ports:
      - "3100:3100"
    command: -config.file=/etc/loki/local-config.yaml
    volumes:
      - loki_data:/loki
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.loki.rule=Host(`loki.digitribe.fr`)"
      - "traefik.http.routers.loki.entrypoints=websecure"
      - "traefik.http.routers.loki.tls.certresolver=letsencrypt"
      - "traefik.http.services.loki.loadbalancer.server.port=3100"

  # Promtail — Log collector (scrapes Docker logs)
  promtail:
    image: grafana/promtail:latest
    container_name: smart-city-promtail
    networks:
      - smartcity-shared
      - traefik-public
    command: -config.file=/etc/promtail/config.yml
    volumes:
      - /var/log:/var/log:ro
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./promtail-config.yml:/etc/promtail/config.yml:ro
      - promtail_data:/tmp/promtail
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.promtail.rule=Host(`promtail.digitribe.fr`)"
      - "traefik.http.routers.promtail.entrypoints=websecure"
      - "traefik.http.routers.promtail.tls.certresolver=letsencrypt"
      - "traefik.http.services.promtail.loadbalancer.server.port=9080"
