Repository: greensheep/plex-server-docker-rpi Branch: master Commit: 50af6ce17e90 Files: 7 Total size: 7.3 KB Directory structure: gitextract_x7s048ld/ ├── .github/ │ └── workflows/ │ └── release.yml ├── Dockerfile ├── LICENSE ├── README.md ├── VERSION └── scripts/ ├── entrypoint.sh └── plex-url.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/release.yml ================================================ name: release on: push: branches: - master jobs: docker: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Set Version id: version run: | echo "::set-output name=VERSION::$(cat VERSION)" - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and Push uses: docker/build-push-action@v2 with: context: . platforms: linux/arm,linux/arm64 push: true tags: greensheep/plex-server-docker-rpi:${{ steps.version.outputs.VERSION }},greensheep/plex-server-docker-rpi:latest ================================================ FILE: Dockerfile ================================================ FROM debian:buster-slim AS src ARG TARGETARCH ENV DEBIAN_FRONTEND="noninteractive" \ PLEX_PATH=/usr/lib/plexmediaserver \ PLEX_USER_NAME=plex \ PLEX_CONFIG_DIR=/config \ PLEX_DATA_DIR=/data \ PLEX_TRANSCODE_DIR=/transcode RUN apt-get update \ && apt-get install -y wget ca-certificates COPY VERSION . COPY scripts/plex-url.sh . # Download / install Plex RUN PLEX_VERSION=$(cat ./VERSION) \ && PLEX_URL=$(./plex-url.sh $PLEX_VERSION $TARGETARCH) \ && wget --no-verbose -O /tmp/plex.deb $PLEX_URL \ && dpkg -i /tmp/plex.deb \ && rm -f /tmp/plexmediaserver.deb # Add user RUN useradd -U -d $PLEX_CONFIG_DIR -s /bin/false $PLEX_USER_NAME \ && usermod -G users $PLEX_USER_NAME COPY scripts/entrypoint.sh . RUN chmod +x entrypoint.sh ENTRYPOINT [ "/entrypoint.sh" ] ================================================ FILE: LICENSE ================================================ The MIT License (MIT) Copyright (c) 2015 Tom Hill Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ Docker images: https://hub.docker.com/r/greensheep/plex-server-docker-rpi/tags # Plex Server for Raspberry Pi A simple way to run a plex media server in Docker on the Raspberry Pi. **NOTE: The Pi 1 is NOT supported.** ## Usage Install docker on your raspberry pi. There are numerous ways to do this but the easiest is to run: ```sh curl -sSL https://get.docker.com | sh ``` _Source: https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi_ Next, you'll need to create three local folders for the plex config, data and transcode volumes (I have all of these on an external HDD because they get very large). For example: ```sh mkdir -p ~/media/plex/{config,data,transcode} ``` Using the above folders, run the following to start plex: ```sh docker run \ -d \ --name plex \ --net host \ --restart always \ --volume $(echo $HOME)/media/plex/config:/config \ --volume $(echo $HOME)/media/plex/data:/data \ --volume $(echo $HOME)/media/plex/transcode:/transcode \ greensheep/plex-server-docker-rpi:latest ``` After around 30 seconds, the Plex web admin should be available at `http://{ip address of Pi}:32400/web`. ## NFS Shares If you have permission issues using NFS shares as the mounted volumes, set the `SET_PLEX_UID` and `SET_PLEX_GID` environment variables to the user/group id of the owner of those directories. ### To find the uid/gid: ``` # show user/group owner of a directory ls -n ~/media/plex/config # outputs something like this: # drwxr-xr-x 20 1001 1001 4096 Apr 9 19:00 config # ^ uid ^ gid ``` ### Updated `docker run`: ```sh docker run \ -d \ --name plex \ --net host \ --restart always \ -e SET_PLEX_UID=1001 \ -e SET_PLEX_GID=1001 \ --volume $(echo $HOME)/media/plex/config:/config \ --volume $(echo $HOME)/media/plex/data:/data \ --volume $(echo $HOME)/media/plex/transcode:/transcode \ greensheep/plex-server-docker-rpi:latest ``` ## Updating Plex cannot be updated via the web ui. Run the following to download and run a new version: ```sh docker pull greensheep/plex-server-docker-rpi:latest docker stop plex docker rm -f plex # `docker run ...` command from above! ``` ## Transcoding The Pi isn't powerful enough for transcoding but if you have media that will direct play on your client it works great! I've tested this on the Pi 2 (Hypriot) and 3 (Arch) and 4 (ubuntu). Be sure to set the "Transcoder temporary directory" setting to `/transcode` in the Plex -> Transcoder settings UI. ## Development To build the images yourself clone this repository and run the following: ```sh sudo docker buildx build -t plex-dev:latest --platform linux/arm,linux/arm64 . ``` ================================================ FILE: VERSION ================================================ 1.40.4.8679-424562606 ================================================ FILE: scripts/entrypoint.sh ================================================ #!/bin/bash set -e PLEX_USER_ID=$(id -u $PLEX_USER_NAME) PLEX_GROUP_ID=$(id -g $PLEX_USER_NAME) echo "=> Plex user id: $PLEX_USER_ID" # If a user id was supplied, and this doesn't match the plex user, update it if [ ! -z "${SET_PLEX_UID}" ]; then if [ ! "$PLEX_USER_ID" -eq "${SET_PLEX_UID}" ]; then # Updating the user id is causing the following error: # usermod: Failed to change ownership of the home directory # To get round this, create a temporary home dir, update the # user id, then set it back TEMP_HOME_DIR=/tmp/plexhomedir mkdir $TEMP_HOME_DIR usermod -d $TEMP_HOME_DIR $PLEX_USER_NAME # Update user id usermod -o -u "${SET_PLEX_UID}" $PLEX_USER_NAME echo "=> Updated plex user id to $SET_PLEX_UID" usermod -d $PLEX_CONFIG_DIR $PLEX_USER_NAME rm -rf $TEMP_HOME_DIR else echo "=> Requested user id ($SET_PLEX_UID) matches plex user id ($PLEX_USER_ID), nothing to do" fi fi echo "=> Plex group id: $PLEX_GROUP_ID" # Same for group id if [ ! -z "${SET_PLEX_GID}" ]; then if [ ! "$PLEX_GROUP_ID" -eq "${SET_PLEX_GID}" ]; then groupmod -o -g "${SET_PLEX_GID}" $PLEX_USER_NAME echo "=> Updated plex group id to $SET_PLEX_GID" else echo "=> Requested group id ($SET_PLEX_GID) matches plex group id ($PLEX_GROUP_ID), nothing to do" fi fi # Remove any previous pid file. Plex wont start if this file is left over from a previous run rm -rf /config/Library/Application\ Support/Plex\ Media\ Server/plexmediaserver.pid # Start plex! echo '=> Starting plex... to load the UI go to: http://{ip address of Pi}:32400/web' echo su plex -s $PLEX_PATH/Plex\ Media\ Server ================================================ FILE: scripts/plex-url.sh ================================================ #!/bin/bash set -e VERSION=$1 case $2 in arm64) TARGETARCH=arm64 ;; arm) TARGETARCH=armhf ;; *) echo "Error: unknown target arch" exit 1 ;; esac echo https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_${TARGETARCH}.deb