## Discord Plex FR : https://discord.gg/ERpYMqS
## Version 2021-08-17
##
##              NOTE : ATTENTION NE PAS BASCULER SUR L'IMAGE CRAZYMAX AVEC LES FICHIERS DE
##                           VOTRE ANCIENNE CONFIG LINUXSERVER/RUTORRENT
## Voir : https://blog.thelazyfox.xyz/docker-linuxserver-rutorrent-deprecated-what-i-have-done/
##
##
## Dans le fichier .env, modifier les variables PUID/GUID avec vos ID 
## Plus d'info : https://www.forum-nas.fr/viewtopic.php?f=56&t=13213
## Modifier également la variable "RACINE" qui doit indiquer le chemin racine
## Dans ce dossier ( par defaut downloads-vpn ) il doit y avoir l'arborescence suivante :
##
##             downloads-vpn ---- vpn ------------ config
##                            |                 |_ scripts
##                            |
##                            |-- rutorrent ------ data
##                            |                 |_ passwd
##                            |                 |_ downloads
##                            |
##                            |-- prowlarr ------- config
##                            |
##                            |-- sonarr --------- config
##                            |                 |_ downloads
##                            |
##                            |-- radarr --------- config
##                            |                 |_ downloads
##                            |
##                            |-- jackett -------- config
##                            |
##                            |-- qbitorrent ----- config
##                            |                 |_ downloads
##

version: '3.2'
      
services: 
  vpn:
    image: dperson/openvpn-client:latest
    container_name: vpn
    restart: unless-stopped
    cap_add:
     - NET_ADMIN
    sysctls:
     - net.ipv6.conf.all.disable_ipv6=0
    security_opt:
     - label:disable
#    labels:
#      - com.centurylinklabs.watchtower.enable=true
#      - autoheal=true
    environment:
     - PUID=${PUID}
     - PGID=${PGID}
     - TZ=${TZ}
    networks:
     - vpn-network
    dns:
     - 84.200.69.80
     - 8.8.8.8
     - 9.9.9.9
    ports :
     - 8586:8586 # WebUI qbittorrent
     - 9117:9117 # WebUI jackett 
     - 7878:7878 # WebUI radarr
     - 8989:8989 # WebUI sonarr
     - 8191:8191 #flaresolver
     - 8080:8080 # WebUI rutorrent crazymax
     - 9696:9696 # WebUI prowlarr
    devices: 
     - /dev/net/tun:/dev/net/tun
    volumes:
     - ${RACINE}/vpn/config:/vpn
     - ${RACINE}/vpn/scripts:/scripts
    command: '-f "" -r 192.168.0.0/24'
    healthcheck:
      test: ["CMD", "curl", "-Ss", "ifconfig.me"]
      interval: 60s
      timeout: 15s

  rtorrent-rutorrent:
    image: crazymax/rtorrent-rutorrent:latest
    container_name: rutorrent-crazymax
#    labels:
#     - com.centurylinklabs.watchtower.enable=true
#     - autoheal=true
    depends_on:
      - vpn
    env_file:
      - "./rtorrent-rutorrent.env"
    environment:
     - PUID=${PUID}
     - PGID=${PGID}
     - TZ=${TZ}
    network_mode: "service:vpn"
    volumes:
      - ${RACINE}/rutorrent/data:/data
      - ${RACINE}/rutorrent/passwd:/passwd
      - ${RACINE}/rutorrent/downloads:/downloads
    ulimits:
      nproc: 65535
      nofile:
        soft: 32000
        hard: 40000
    restart: unless-stopped
#    healthcheck:
#     test: ["CMD-SHELL", "curl --fail http://172.22.0.1:8080/ || exit 1"]
#     interval: 1m30s
#     timeout: 10s
#     retries: 3

  prowlarr:
    image: ghcr.io/linuxserver/prowlarr:develop
    container_name: prowlarr
    network_mode: "service:vpn"
    depends_on:
      - vpn
#    labels:
#      - com.centurylinklabs.watchtower.enable=true
#      - autoheal=true
    environment:
     - PUID=${PUID}
     - PGID=${PGID}
     - TZ=${TZ}
#     - DOCKER_MODS=ghcr.io/gilbn/theme.park:prowlarr
#     - TP_THEME=space-gray
    volumes:
      - ${RACINE}/prowlarr/config:/config
    restart: unless-stopped
#    healthcheck:
#     test: ["CMD-SHELL", "curl --fail http://172.22.0.1:9696/ || exit 1"]
#     interval: 1m30s
#     timeout: 10s
#     retries: 3
      
  sonarr:
    image: ghcr.io/linuxserver/sonarr:latest
    container_name: sonarr
    depends_on:
      - vpn
    network_mode: "service:vpn"
#    labels:
#      - autoheal=true
#      - com.centurylinklabs.watchtower.enable=true
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    volumes:
      - ${RACINE}/sonarr/config:/config
      - ${RACINE}/rutorrent/downloads:/downloads
    restart: unless-stopped
#    healthcheck:
#     test: ["CMD-SHELL", "curl --fail http://172.22.0.1:8989/ || exit 1"]
#     interval: 1m30s
#     timeout: 10s
#     retries: 3
    
  radarr:
    image: ghcr.io/linuxserver/radarr:nightly
    container_name: radarr
    depends_on:
      - vpn
    network_mode: "service:vpn"
#    labels:
#      - autoheal=true
#      - com.centurylinklabs.watchtower.enable=true
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    volumes:
      - ${RACINE}/radarr/config:/config
      - ${RACINE}/rutorrent/downloads:/downloads
    restart: unless-stopped
#    healthcheck:
#     test: ["CMD-SHELL", "curl --fail http://172.22.0.1:7878/ || exit 1"]
#     interval: 1m30s
#     timeout: 10s
#     retries: 3  
    
  jackett:
    image: ghcr.io/linuxserver/jackett
    container_name: jackett
    depends_on:
      - vpn
    network_mode: "service:vpn"
#    labels:
#      - autoheal=true
#      - com.centurylinklabs.watchtower.enable=true
    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
    volumes:
      - ${RACINE}/jackett/config:/config
      - ${RACINE}/jackett/downloads:/downloads
    restart: unless-stopped
#    healthcheck:
#     test: ["CMD-SHELL", "curl --fail http://172.22.0.1:9117/ || exit 1"]
#     interval: 1m30s
#     timeout: 10s
#     retries: 3
    
  flaresolverr:
    image: ghcr.io/flaresolverr/flaresolverr
    container_name: flaresolverr
    network_mode: "service:vpn"
    depends_on:
      - vpn
#    labels:
#      - com.centurylinklabs.watchtower.enable=true
    environment:
      - LOG_LEVEL=info
    restart: unless-stopped

  qbittorrent:
    image: ghcr.io/linuxserver/qbittorrent
    container_name: qbittorrent
#    labels:
#     - autoheal=true
#     - com.centurylinklabs.watchtower.enable=true
    depends_on:
     - vpn
    network_mode: "service:vpn"
    environment:
     - PUID=${PUID}
     - PGID=${PGID}
     - TZ=${TZ}
     - WEBUI_PORT=8586
    volumes:
     - ${RACINE}/qbittorrent/config:/config
     - ${RACINE}/qbittorrent/downloads:/downloads
    restart: unless-stopped
#    healthcheck:
#     test: ["CMD-SHELL", "curl --fail http://172.22.0.1:8586/ || exit 1"]
#     interval: 1m30s
#     timeout: 10s
#     retries: 3

networks:
  vpn-network:
    external:
      name: vpn-network
