Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arm64 support and Update Plex Download URLs to latest API #48

Merged
merged 6 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
docker-compose.yml

test/
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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 && \
Expand Down
60 changes: 60 additions & 0 deletions Dockerfile.arm64
Original file line number Diff line number Diff line change
@@ -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
maxlabuche marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion root/etc/cont-init.d/50-plex-update
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion root/installBinary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
26 changes: 25 additions & 1 deletion root/plex-common.sh
Original file line number Diff line number Diff line change
@@ -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)"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanations for reading value :

Expecting file should be like:

version=beta
plex-distro=debian
...

Value is : look for variable name (grep), then take the part after the '=' sign (cut), then take the last value if multiple (tail) (that should not happen but in case).

else
value=NULL
fi
}

Comment on lines +3 to +22
Copy link
Contributor Author

@maxlabuche maxlabuche Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gbooker I think there are better ways to write different variables to a "conf" file, but I wanted to keep things simple given that these variables are written once in this file (while building the image), then they are read only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the values are written once and in only one place, the function to add them isn't really needed (doesn't hurt though). I was expecting just a

echo "version=${TAG}" > /version.txt
echo "plex_build=${PLEX_BUILD}" >> /version.txt
echo "plex_distro=${PLEX_DISTRO}" >> /version.txt

but the above should work too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly I was thinking to write the same lines at the beginning like you are suggesting. At least if at some point we need to have such as a function, we just have to modify the behaviour of this one

function getVersionInfo {
local version="$1"
local token="$2"
Expand All @@ -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
Expand Down