[
  {
    "path": ".github/workflows/release.yml",
    "content": "name: release\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  docker:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n      - name: Set Version\n        id: version\n        run: |\n          echo \"::set-output name=VERSION::$(cat VERSION)\"\n      - name: Set up QEMU\n        uses: docker/setup-qemu-action@v1\n      - name: Set up Docker Buildx\n        uses: docker/setup-buildx-action@v1\n      - name: Login to DockerHub\n        uses: docker/login-action@v1\n        with:\n          username: ${{ secrets.DOCKERHUB_USERNAME }}\n          password: ${{ secrets.DOCKERHUB_TOKEN }}\n      - name: Build and Push\n        uses: docker/build-push-action@v2\n        with:\n          context: .\n          platforms: linux/arm,linux/arm64\n          push: true\n          tags: greensheep/plex-server-docker-rpi:${{ steps.version.outputs.VERSION }},greensheep/plex-server-docker-rpi:latest\n"
  },
  {
    "path": "Dockerfile",
    "content": "FROM debian:buster-slim AS src\n\nARG TARGETARCH\n\nENV DEBIAN_FRONTEND=\"noninteractive\" \\\n  PLEX_PATH=/usr/lib/plexmediaserver \\\n  PLEX_USER_NAME=plex \\\n  PLEX_CONFIG_DIR=/config \\\n  PLEX_DATA_DIR=/data \\\n  PLEX_TRANSCODE_DIR=/transcode\n\nRUN apt-get update \\\n  && apt-get install -y wget ca-certificates\n\nCOPY VERSION .\nCOPY scripts/plex-url.sh .\n\n# Download / install Plex\nRUN PLEX_VERSION=$(cat ./VERSION) \\\n && PLEX_URL=$(./plex-url.sh $PLEX_VERSION $TARGETARCH) \\\n && wget --no-verbose -O /tmp/plex.deb $PLEX_URL \\\n && dpkg -i /tmp/plex.deb \\\n && rm -f /tmp/plexmediaserver.deb\n\n# Add user\nRUN useradd -U -d $PLEX_CONFIG_DIR -s /bin/false $PLEX_USER_NAME \\\n && usermod -G users $PLEX_USER_NAME\n\nCOPY scripts/entrypoint.sh .\nRUN chmod +x entrypoint.sh\n\nENTRYPOINT [ \"/entrypoint.sh\" ]\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Tom Hill\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "README.md",
    "content": "Docker images: https://hub.docker.com/r/greensheep/plex-server-docker-rpi/tags\n\n# Plex Server for Raspberry Pi\n\nA simple way to run a plex media server in Docker on the Raspberry Pi.\n\n**NOTE: The Pi 1 is NOT supported.**\n\n## Usage\n\nInstall docker on your raspberry pi. There are numerous ways to do this but the easiest is to run:\n\n```sh\ncurl -sSL https://get.docker.com | sh\n```\n\n_Source: https://www.raspberrypi.org/blog/docker-comes-to-raspberry-pi_\n\nNext, 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:\n\n```sh\nmkdir -p ~/media/plex/{config,data,transcode}\n```\n\nUsing the above folders, run the following to start plex:\n\n```sh\ndocker run \\\n  -d \\\n  --name plex \\\n  --net host \\\n  --restart always \\\n  --volume $(echo $HOME)/media/plex/config:/config \\\n  --volume $(echo $HOME)/media/plex/data:/data \\\n  --volume $(echo $HOME)/media/plex/transcode:/transcode \\\n  greensheep/plex-server-docker-rpi:latest\n```\n\nAfter around 30 seconds, the Plex web admin should be available at `http://{ip address of Pi}:32400/web`.\n\n## NFS Shares\n\nIf 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.\n\n### To find the uid/gid:\n\n```\n# show user/group owner of a directory\nls -n ~/media/plex/config\n\n# outputs something like this:\n# drwxr-xr-x 20 1001  1001  4096 Apr  9 19:00 config\n#               ^ uid ^ gid\n```\n\n### Updated `docker run`:\n\n```sh\ndocker run \\\n  -d \\\n  --name plex \\\n  --net host \\\n  --restart always \\\n  -e SET_PLEX_UID=1001 \\\n  -e SET_PLEX_GID=1001 \\\n  --volume $(echo $HOME)/media/plex/config:/config \\\n  --volume $(echo $HOME)/media/plex/data:/data \\\n  --volume $(echo $HOME)/media/plex/transcode:/transcode \\\n  greensheep/plex-server-docker-rpi:latest\n```\n\n## Updating\n\nPlex cannot be updated via the web ui. Run the following to download and run a new version:\n\n```sh\ndocker pull greensheep/plex-server-docker-rpi:latest\ndocker stop plex\ndocker rm -f plex\n# `docker run ...` command from above!\n```\n\n## Transcoding\n\nThe 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).\n\nBe sure to set the \"Transcoder temporary directory\" setting to `/transcode` in the Plex -> Transcoder settings UI.\n\n## Development\n\nTo build the images yourself clone this repository and run the following:\n\n```sh\nsudo docker buildx build -t plex-dev:latest --platform linux/arm,linux/arm64 .\n```\n"
  },
  {
    "path": "VERSION",
    "content": "1.40.4.8679-424562606"
  },
  {
    "path": "scripts/entrypoint.sh",
    "content": "#!/bin/bash\n\nset -e\n\nPLEX_USER_ID=$(id -u $PLEX_USER_NAME)\nPLEX_GROUP_ID=$(id -g $PLEX_USER_NAME)\n\necho \"=> Plex user id: $PLEX_USER_ID\"\n\n# If a user id was supplied, and this doesn't match the plex user, update it\nif [ ! -z \"${SET_PLEX_UID}\" ]; then\n  if [ ! \"$PLEX_USER_ID\" -eq \"${SET_PLEX_UID}\" ]; then\n\n    # Updating the user id is causing the following error:\n    # usermod: Failed to change ownership of the home directory\n    # To get round this, create a temporary home dir, update the\n    # user id, then set it back\n    TEMP_HOME_DIR=/tmp/plexhomedir\n    mkdir $TEMP_HOME_DIR\n    usermod -d $TEMP_HOME_DIR $PLEX_USER_NAME\n\n    # Update user id\n    usermod -o -u \"${SET_PLEX_UID}\" $PLEX_USER_NAME\n    echo \"=> Updated plex user id to $SET_PLEX_UID\"\n\n    usermod -d $PLEX_CONFIG_DIR $PLEX_USER_NAME\n    rm -rf $TEMP_HOME_DIR\n\n  else\n    echo \"=> Requested user id ($SET_PLEX_UID) matches plex user id ($PLEX_USER_ID), nothing to do\"\n  fi\nfi\n\necho \"=> Plex group id: $PLEX_GROUP_ID\"\n\n# Same for group id\nif [ ! -z \"${SET_PLEX_GID}\" ]; then\n  if [ ! \"$PLEX_GROUP_ID\" -eq \"${SET_PLEX_GID}\" ]; then\n    groupmod -o -g \"${SET_PLEX_GID}\" $PLEX_USER_NAME\n    echo \"=> Updated plex group id to $SET_PLEX_GID\"\n  else\n    echo \"=> Requested group id ($SET_PLEX_GID) matches plex group id ($PLEX_GROUP_ID), nothing to do\"\n  fi\nfi\n\n# Remove any previous pid file. Plex wont start if this file is left over from a previous run\nrm -rf /config/Library/Application\\ Support/Plex\\ Media\\ Server/plexmediaserver.pid\n\n# Start plex!\necho '=> Starting plex... to load the UI go to: http://{ip address of Pi}:32400/web'\necho\nsu plex -s $PLEX_PATH/Plex\\ Media\\ Server\n"
  },
  {
    "path": "scripts/plex-url.sh",
    "content": "#!/bin/bash\n\nset -e\n\nVERSION=$1\n\ncase $2 in\n  arm64)\n    TARGETARCH=arm64\n    ;;\n  arm)\n    TARGETARCH=armhf\n    ;;\n  *)\n    echo \"Error: unknown target arch\"\n    exit 1\n    ;;\nesac\n\necho https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_${TARGETARCH}.deb\n"
  }
]