From 4d069dc46541f535a6d40fb4e26744fd69060bac Mon Sep 17 00:00:00 2001 From: Maxime Marmont <24413033+maxlabuche@users.noreply.github.com> Date: Tue, 7 Apr 2020 16:33:24 +0200 Subject: [PATCH] Add arm64 support and Update Plex Download URLs to latest API (#48) Add arm64 support and Update Plex Download URLs to latest API --- .gitignore | 2 + Dockerfile | 9 +++-- Dockerfile.arm64 | 60 +++++++++++++++++++++++++++++ root/etc/cont-init.d/50-plex-update | 2 +- root/installBinary.sh | 5 ++- root/plex-common.sh | 26 ++++++++++++- 6 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 Dockerfile.arm64 diff --git a/.gitignore b/.gitignore index 1120be9a..8b1ad47b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ docker-compose.yml + +test/ diff --git a/Dockerfile b/Dockerfile index be500397..df6e1ed5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ FROM ubuntu:16.04 -ARG S6_OVERLAY_VERSION=v1.17.2.0 +ARG S6_OVERLAY_VERSION=v1.22.1.0 +ARG S6_OVERLAY_ARCH=amd64 +ARG PLEX_BUILD=linux-x86_64 +ARG PLEX_DISTRO=debian ARG DEBIAN_FRONTEND="noninteractive" ENV TERM="xterm" LANG="C.UTF-8" LC_ALL="C.UTF-8" @@ -18,8 +21,8 @@ RUN \ && \ # Fetch and extract S6 overlay - curl -J -L -o /tmp/s6-overlay-amd64.tar.gz https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-amd64.tar.gz && \ - tar xzf /tmp/s6-overlay-amd64.tar.gz -C / && \ + curl -J -L -o /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.gz https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.gz && \ + tar xzf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.gz -C / && \ # Add user useradd -U -d /config -s /bin/false plex && \ diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 new file mode 100644 index 00000000..733ed256 --- /dev/null +++ b/Dockerfile.arm64 @@ -0,0 +1,60 @@ +FROM ubuntu:16.04 + +ARG S6_OVERLAY_VERSION=v1.22.1.0 +ARG S6_OVERLAY_ARCH=aarch64 +ARG PLEX_BUILD=linux-aarch64 +ARG PLEX_DISTRO=debian +ARG DEBIAN_FRONTEND="noninteractive" +ENV TERM="xterm" LANG="C.UTF-8" LC_ALL="C.UTF-8" + +ENTRYPOINT ["/init"] + +RUN \ +# Update and get dependencies + apt-get update && \ + apt-get install -y \ + tzdata \ + curl \ + xmlstarlet \ + uuid-runtime \ + unrar \ + && \ + +# Fetch and extract S6 overlay + curl -J -L -o /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.gz https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.gz && \ + tar xzf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.gz -C / && \ + +# Add user + useradd -U -d /config -s /bin/false plex && \ + usermod -G users plex && \ + +# Setup directories + mkdir -p \ + /config \ + /transcode \ + /data \ + && \ + +# Cleanup + apt-get -y autoremove && \ + apt-get -y clean && \ + rm -rf /var/lib/apt/lists/* && \ + rm -rf /tmp/* && \ + rm -rf /var/tmp/* + +EXPOSE 32400/tcp 3005/tcp 8324/tcp 32469/tcp 1900/udp 32410/udp 32412/udp 32413/udp 32414/udp +VOLUME /config /transcode + +ENV CHANGE_CONFIG_DIR_OWNERSHIP="true" \ + HOME="/config" + +ARG TAG=beta +ARG URL= + +COPY root/ / + +RUN \ +# Save version and install + /installBinary.sh + +HEALTHCHECK --interval=5s --timeout=2s --retries=20 CMD /healthcheck.sh || exit 1 diff --git a/root/etc/cont-init.d/50-plex-update b/root/etc/cont-init.d/50-plex-update index 9f00979a..dbaec382 100755 --- a/root/etc/cont-init.d/50-plex-update +++ b/root/etc/cont-init.d/50-plex-update @@ -27,7 +27,7 @@ else fi # Read set version -versionToInstall="$(cat /version.txt)" +readVarFromConf "version" versionToInstall if [ -z "${versionToInstall}" ]; then echo "No version specified in install. Broken image" exit 1 diff --git a/root/installBinary.sh b/root/installBinary.sh index c358932d..a3a62a49 100755 --- a/root/installBinary.sh +++ b/root/installBinary.sh @@ -2,7 +2,10 @@ . /plex-common.sh -echo "${TAG}" > /version.txt +addVarToConf "version" "${TAG}" +addVarToConf "plex_build" "${PLEX_BUILD}" +addVarToConf "plex_distro" "${PLEX_DISTRO}" + if [ ! -z "${URL}" ]; then echo "Attempting to install from URL: ${URL}" installFromRawUrl "${URL}" diff --git a/root/plex-common.sh b/root/plex-common.sh index 0fa7c08a..efd3f36c 100755 --- a/root/plex-common.sh +++ b/root/plex-common.sh @@ -1,5 +1,25 @@ #!/bin/bash +CONT_CONF_FILE="/version.txt" + +function addVarToConf { + local variable="$1" + local value="$2" + if [ ! -z "${variable}" ]; then + echo ${variable}=${value} >> ${CONT_CONF_FILE} + fi +} + +function readVarFromConf { + local variable="$1" + declare -n value=$2 + if [ ! -z "${variable}" ]; then + value="$(grep -w ${variable} ${CONT_CONF_FILE} | cut -d'=' -f2 | tail -n 1)" + else + value=NULL + fi +} + function getVersionInfo { local version="$1" local token="$2" @@ -19,7 +39,11 @@ function getVersionInfo { channel=8 fi - local url="https://plex.tv/downloads/details/1?build=linux-ubuntu-x86_64&channel=${channel}&distro=ubuntu" + # Read container architecture info from file created when building Docker image + readVarFromConf "plex_build" plexBuild + readVarFromConf "plex_distro" plexDistro + + local url="https://plex.tv/downloads/details/5?build=${plexBuild}&channel=${channel}&distro=${plexDistro}" if [ ${tokenNeeded} -gt 0 ]; then url="${url}&X-Plex-Token=${token}" fi