services:
  gluetun:
    image: qmcgaw/gluetun:latest
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
    cpus: 1.0
    mem_limit: "1024m"
    mem_reservation: "128m"
    environment:
      # Core VPN config
      - VPN_SERVICE_PROVIDER=airvpn
      - VPN_TYPE=wireguard

      # From your WireGuard config:
      - WIREGUARD_PRIVATE_KEY=ECCy5yvuw44r9gwVBV0dm6lkwYgj9TooW1FEj4LK8X4=
      - WIREGUARD_PRESHARED_KEY=3eL2dzBilN+dmKGGXwOzUwGKpBJkKZELos/6GurIb/8=    # if present in config
      - WIREGUARD_ADDRESSES=10.186.81.191/32                 # from your [Interface] Address
      # Endpoint — use resolved IP instead of domain:
      - SERVER_COUNTRIES=Canada
      #- WIREGUARD_ENDPOINT_IP=184.75.223.197  
      #- WIREGUARD_ENDPOINT_PORT=1637                         # matches AirVPN WG port

      # Port forwarding for torrenting
      - FIREWALL_VPN_INPUT_PORTS=30754

    ports:
      - 8080:8080            # qBittorrent Web UI
      - 30754:30754          # torrent port TCP
      - 30754:30754/udp      # torrent port UDP

  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: qbittorrent
    network_mode: "service:gluetun"
    cpus: 4.0
    mem_limit: "8192m"       # 8 GB
    mem_reservation: "2048m" # 2 GB
    ulimits:
      nproc: 65535
      nofile:
        soft: 65535
        hard: 65535
    depends_on:
      - gluetun
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - WEBUI_PORT=8080
      - TORRENTING_PORT=30754
    volumes:
      - /docker/qbittorrent/data:/config
      - /pool/torrenting:/downloads
      - /pool/music:/mnt/music
      - /pool/tv:/mnt/tv
      - /pool/movies:/mnt/movies
      - /pool/other:/mnt/other
      - /mnt/SATA-22TB-host15/qbittorrent/downloads:/q-downloads
      - /mnt/SATA-22TB-host15/qbittorrent/completed:/q-completed
      - /mnt/SATA-22TB-host15/qbittorrent/seeding:/q-seeding
    restart: unless-stopped

