services:
    loki:
        command:
            - -config.file=/etc/loki/config.yaml
        container_name: loki
        image: grafana/loki:latest
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik: null
        restart: always
        privileged: true
        user: root
        volumes:
            - db:/loki
            - loki_config:/etc/loki

    promtail:
        command:
            - -config.file=/etc/promtail/config.yml
        container_name: loki_promtail
        depends_on:
            - loki
        image: grafana/promtail:latest
        labels:
            traefik.docker.network: traefik
            traefik.enable: true
            traefik.http.routers.promtail.entrypoints: websecure
            traefik.http.routers.promtail.rule: Host(`promtail.alexlebens.net`)
            traefik.http.routers.promtail.service: promtail
            traefik.http.routers.promtail.middlewares: authentik@file
            traefik.http.services.promtail.loadbalancer.server.port: 9080
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik: null
        restart: always
        privileged: true
        user: root
        volumes:
            - /var/lib/docker/containers:/var/lib/docker/containers
            - /var/run/docker.sock:/var/run/docker.sock
            - /var/log:/var/log
            - promtail_config:/etc/promtail

networks:
    traefik:
        name: traefik
        external: true

volumes:
    db:
        driver: local
        driver_opts:
            type: none
            o: bind
            device: /var/lib/docker/volumes/partition/loki_db

    loki_config:
        driver: local
        driver_opts:
            type: none
            o: bind
            device: /var/lib/docker/volumes/partition/loki_config

    promtail_config:
        driver: local
        driver_opts:
            type: none
            o: bind
            device: /var/lib/docker/volumes/partition/promtail_config
