services:
    qbittorrent:
        cap_add:
            - NET_ADMIN
            - SYS_MODULE
        container_name: qbittorrent
        env_file:
            - .env
        image: dyonr/qbittorrentvpn
        labels:
            traefik.docker.network: traefik
            traefik.enable: true
            traefik.http.routers.qbittorrent.entrypoints: websecure
            traefik.http.routers.qbittorrent.rule: Host(`qbittorrent.alexlebens.net`)
            traefik.http.routers.qbittorrent.service: qbittorrent
            traefik.http.routers.qbittorrent.middlewares: qbittorrent-theme@file
            traefik.http.services.qbittorrent.loadbalancer.server.port: 8080
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik:
                ipv4_address: 172.27.1.20
        privileged: true
        restart: always
        sysctls:
            - net.ipv6.conf.all.disable_ipv6=0
            - net.ipv4.conf.all.src_valid_mark=1
        user: root
        volumes:
            - config:/config
            - downloads:/downloads
            - torrent_nfs:/mnt/store/Torrent

    qbittorrent_exporter:
        container_name: qbittorrent_exporter
        depends_on:
            - qbittorrent
        env_file:
            - .exp.env
        image: esanchezm/prometheus-qbittorrent-exporter
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik:
                ipv4_address: 172.27.1.21
        restart: always

    unpackerr:
        container_name: qbittorrent_unpackerr
        env_file:
            - .unp.env
        image: hotio/unpackerr
        logging:
            driver: json-file
            options:
                max-size: 50m
                max-file: "3"
        networks:
            traefik: null
        restart: always
        privileged: true
        user: root
        security_opt:
            - no-new-privileges:true
        volumes:
            - unpconfig:/config
            - unplogs:/tmp
            - torrent_nfs_finished:/mnt/store/Torrent/FINISHED

networks:
    traefik:
        name: traefik
        external: true

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

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

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

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

#    torrent_cifs_finished:
#        driver: local
#        driver_opts:
#            type: cifs
#            o: username=storage,password=24wrsfxv@$$WRSFXV,file_mode=0777,dir_mode=0777
#            device: //192.168.1.194/Storage/Torrent/FINISHED

#    torrent_nfs_downloading:
#        driver: local
#        driver_opts:
#            type: nfs
#            o: addr=192.168.1.194,nfsvers=4
#            device: :/volume2/Storage/Torrent/DOWNLOADING

#    torrent_nfs_torrent:
#        driver: local
#        driver_opts:
#            type: nfs
#            o: addr=192.168.1.194,nfsvers=4
#            device: :/volume2/Storage/Torrent/TORRENT

    torrent_nfs:
        driver: local
        driver_opts:
            type: nfs
            o: addr=192.168.1.194,nfsvers=4
            device: :/volume2/Storage/Torrent

    torrent_nfs_finished:
        driver: local
        driver_opts:
            type: nfs
            o: addr=192.168.1.194,nfsvers=4
            device: :/volume2/Storage/Torrent/FINISHED
