version: '3.3'
services:
    pms-docker:
        container_name: plex
        image: plexinc/pms-docker:latest
        restart: unless-stopped
        devices:
            - /dev/dri:/dev/dri
        volumes:
            - '/home/ubuntu/docker/plex/config:/config'
            - '/home/ubuntu/docker/plex/temp:/transcode'
            - '/home/ubuntu/docker/plex/data:/data'
            - '/home/ubuntu/freenas/Films:/Films:ro' #set to read-only
            - '/home/ubuntu/freenas/TVShows:/TVShows:ro' #set to read-only
        ports:
            - 32400:32400/tcp # only port that is strictly required
            - 32400:32400/udp
            - 3005:3005/tcp
            - 8324:8324/tcp
            - 32469:32469/tcp
            - 1900:1900/udp
            - 32410:32410/udp
            - 32412:32412/udp
            - 32413:32413/udp
            - 32414:32414/udp
        environment:
            - TZ=Europe/London
            - PLEX_CLAIM=claim-w9VAXV8FTCZcnxGSLQTQ # get this from plex.tv/claim
            - ADVERTISE_IP=https://plex.yourdomain.com:443 #change me
            - ALLOWED_NETWORKS=192.168.0.0/16 # place trusted network ranges here
        networks:
          proxy:
        labels:
          - "traefik.enable=true"
          - "traefik.http.routers.plex.entrypoints=http"
          - "traefik.http.routers.plex.rule=Host(`plex.yourdomain.com`)" # change me
          - "traefik.http.middlewares.plex-https-redirect.redirectscheme.scheme=https"
          - "traefik.http.routers.plex.middlewares=plex-https-redirect"
          - "traefik.http.routers.plex-secure.entrypoints=https"
          - "traefik.http.routers.plex-secure.rule=Host(`plex.yourdomain.com`)" #change me
          - "traefik.http.routers.plex-secure.tls=true"
          - "traefik.http.routers.plex-secure.service=plex"
          - "traefik.http.services.plex.loadbalancer.server.port=32400"
          - "traefik.http.services.plex.loadbalancer.server.scheme=https"
          - "traefik.docker.network=proxy"
        security_opt:
          - no-new-privileges:true

networks:
  proxy:
     external: true
