services:
  jellyfin:
    image: lscr.io/linuxserver/jellyfin:latest
    container_name: jellyfin
    ports:
      - "8096:8096"
    #runtime: nvidia
    environment:
      - TZ=America/Edmonton
      - JELLYFIN_DATA_DIR=/config
      - JELLYFIN_CONFIG_DIR=/config/config
      - JELLYFIN_CACHE_DIR=/cache
      - JELLYFIN_LOG_DIR=/config/log
      - PUID=1000
      - PGID=1000
      #- NVIDIA_VISIBLE_DEVICES=all
      #- NVIDIA_DRIVER_CAPABILITIES=all
      - TRANSCODE_OPERATING_MODE=ram
    volumes:
      - /docker/mediaservices/jellyfin/config:/config
      - /docker/mediaservices/jellyfin/cache:/cache
      - /pool/music:/music
      - /pool/tv:/tv
      - /pool/movies:/movies
      - /dev/shm:/transcode
    cpus: "4.0"
    mem_limit: "12288m"
    mem_reservation: "4096m"
    ulimits:
      nproc: 65535
      nofile:
        soft: 65535
        hard: 65535
    restart: unless-stopped
    labels:
      - "traefik.enable=true"
        # Router
      - "traefik.http.routers.jellyfin.rule=Host(`media.mapletree.email`)"
      - "traefik.http.routers.jellyfin.entrypoints=web,websecure"
      - "traefik.http.routers.jellyfin.tls.certresolver=myresolver"
      # Service (points to internal port)
      - "traefik.http.services.jellyfin.loadbalancer.server.port=8096"

    networks:
      - jellyfin_external

networks:
  jellyfin_external:
    external: true
