version: "3.8"

# Local Grafana Loki + Grafana stack for testing Playwright integration
# Usage: docker-compose -f docker-compose.loki.yml up -d

services:
  loki:
    image: grafana/loki:2.9.0
    container_name: thrillwiki-loki
    ports:
      - "3100:3100"
    volumes:
      - ./loki-config.yml:/etc/loki/local-config.yaml
      - loki-data:/loki
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - loki-network
    restart: unless-stopped

  grafana:
    image: grafana/grafana:10.1.0
    container_name: thrillwiki-grafana
    ports:
      - "3000:3000"
    environment:
      - GF_AUTH_ANONYMOUS_ENABLED=true
      - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
      - GF_SECURITY_ADMIN_PASSWORD=admin
      - GF_USERS_ALLOW_SIGN_UP=false
      - GF_SERVER_ROOT_URL=http://localhost:3000
    volumes:
      - grafana-data:/var/lib/grafana
      - ./grafana-datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml
      - ./monitoring/grafana-dashboard.json:/etc/grafana/provisioning/dashboards/playwright-dashboard.json
    networks:
      - loki-network
    depends_on:
      - loki
    restart: unless-stopped

  # Optional: Promtail for collecting logs from files
  # promtail:
  #   image: grafana/promtail:2.9.0
  #   container_name: thrillwiki-promtail
  #   volumes:
  #     - ./promtail-config.yml:/etc/promtail/config.yml
  #     - ./test-results:/var/log/playwright:ro
  #   command: -config.file=/etc/promtail/config.yml
  #   networks:
  #     - loki-network
  #   depends_on:
  #     - loki
  #   restart: unless-stopped

volumes:
  loki-data:
    driver: local
  grafana-data:
    driver: local

networks:
  loki-network:
    driver: bridge
