services:
    postgres:
        container_name: outline_postgres
        env_file: 
            - .env
        image: postgres:14
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik: null
        restart: unless-stopped
        volumes:
            - postgres:/var/lib/postgresql/data

    redis:
        container_name: outline_redis
        env_file: 
            - .env
        healthcheck:
            test: [ "CMD", "redis-cli", "ping" ]
            interval: 10s
            timeout: 30s
            retries: 3
        image: redis:7
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik: null
        restart: unless-stopped
        volumes:
            - redis:/data

    outline:
        container_name: outline_server
        depends_on:
            - postgres
            - redis
        env_file: 
            - .env
        image: outlinewiki/outline:latest
        labels:
            traefik.docker.network: traefik
            traefik.enable: true
            traefik.http.routers.outline.entrypoints: websecure
            traefik.http.routers.outline.rule: Host(`outline.alexlebens.net`)
            traefik.http.routers.outline.service: outline
            traefik.http.services.outline.loadbalancer.server.port: 3000
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik: null
        restart: always

networks:
    traefik:
        name: traefik
        external: true

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

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

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