Skip to content

Commit

Permalink
Alpine base image
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhotio committed Mar 5, 2024
1 parent 93f86a4 commit 5fc1431
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 81 deletions.
6 changes: 3 additions & 3 deletions VERSION.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"test_amd64": true,
"test_arm64": true,
"test_url": "http://localhost:32400/web",
"upstream_digest_amd64": "sha256:12b5a7e0fc18cd698a56c6b2fadf3472e62201ad441e896dc0f13a5e73021349",
"upstream_digest_arm64": "sha256:0a039eb78a35179d86868b9401ac8f5d4d9c01c064982a39614ddc035d9f74b0",
"upstream_digest_amd64": "sha256:9148bd5af7b67646882351563e8d917f05f1d67e14b9c632b19d613cf28bd415",
"upstream_digest_arm64": "sha256:188ae19dd13c8fa837e3552e54e0e0116cb9ac370fbeb842bf71a1cadd914dd5",
"upstream_image": "ghcr.io/hotio/base",
"upstream_tag": "jammyvpn",
"upstream_tag": "alpinevpn",
"version": "1.40.0.7998-c29d4c0c8"
}
21 changes: 10 additions & 11 deletions linux-amd64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ VOLUME ["/transcode"]
ARG IMAGE_STATS
ENV IMAGE_STATS=${IMAGE_STATS} WEBUI_PORTS="32400/tcp,32400/udp" PLEX_CLAIM_TOKEN="" PLEX_ADVERTISE_URL="" PLEX_NO_AUTH_NETWORKS="" PLEX_BETA_INSTALL="false" PLEX_PURGE_CODECS="false"

ARG DEBIAN_FRONTEND="noninteractive"
# install packages
RUN apt update && \
apt install -y --no-install-recommends --no-install-suggests \
xmlstarlet && \
# clean up
apt autoremove -y && \
apt clean && \
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
RUN apk add --no-cache dpkg && \
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community xmlstarlet

# install plex
ARG VERSION
RUN debfile="/tmp/plex.deb" && wget2 -nc -O "${debfile}" "https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_amd64.deb" && dpkg -i "${debfile}" && rm "${debfile}" && echo "${VERSION}" > "${APP_DIR}/version" && \
mkdir "${APP_DIR}/config" && ln -s "${CONFIG_DIR}" "${APP_DIR}/config/Plex Media Server"
RUN debfile="/tmp/plex.deb" && \
mkdir "${APP_DIR}/bin" && \
curl -fsSL "https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_amd64.deb" -o "${debfile}" && \
dpkg-deb -x "${debfile}" "${APP_DIR}/bin" && \
rm "${debfile}" && \
echo "${VERSION}" > "${APP_DIR}/version" && \
mkdir "${APP_DIR}/config" && \
ln -s "${CONFIG_DIR}" "${APP_DIR}/config/Plex Media Server"

COPY root/ /
21 changes: 10 additions & 11 deletions linux-arm64.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ VOLUME ["/transcode"]
ARG IMAGE_STATS
ENV IMAGE_STATS=${IMAGE_STATS} WEBUI_PORTS="32400/tcp,32400/udp" PLEX_CLAIM_TOKEN="" PLEX_ADVERTISE_URL="" PLEX_NO_AUTH_NETWORKS="" PLEX_BETA_INSTALL="false" PLEX_PURGE_CODECS="false"

ARG DEBIAN_FRONTEND="noninteractive"
# install packages
RUN apt update && \
apt install -y --no-install-recommends --no-install-suggests \
xmlstarlet && \
# clean up
apt autoremove -y && \
apt clean && \
rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/*
RUN apk add --no-cache dpkg && \
apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community xmlstarlet

# install plex
ARG VERSION
RUN debfile="/tmp/plex.deb" && wget2 -nc -O "${debfile}" "https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_arm64.deb" && dpkg -i "${debfile}" && rm "${debfile}" && echo "${VERSION}" > "${APP_DIR}/version" && \
mkdir "${APP_DIR}/config" && ln -s "${CONFIG_DIR}" "${APP_DIR}/config/Plex Media Server"
RUN debfile="/tmp/plex.deb" && \
mkdir "${APP_DIR}/bin" && \
curl -fsSL "https://downloads.plex.tv/plex-media-server-new/${VERSION}/debian/plexmediaserver_${VERSION}_arm64.deb" -o "${debfile}" && \
dpkg-deb -x "${debfile}" "${APP_DIR}/bin" && \
rm "${debfile}" && \
echo "${VERSION}" > "${APP_DIR}/version" && \
mkdir "${APP_DIR}/config" && \
ln -s "${CONFIG_DIR}" "${APP_DIR}/config/Plex Media Server"

COPY root/ /
111 changes: 64 additions & 47 deletions root/etc/s6-overlay/s6-rc.d/init-setup-app/run
Original file line number Diff line number Diff line change
Expand Up @@ -117,47 +117,83 @@ fi
# Remove pid file
rm -f "${CONFIG_DIR}/plexmediaserver.pid"

#############
## HW Support
DEVICES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)

for i in ${DEVICES}; do
# Get the group ID and NAME (if exists) for the current device in the list
DEVICE_GROUP_ID=$(stat -c '%g' "$i")
DEVICE_GROUP_NAME=$(getent group "${DEVICE_GROUP_ID}" | awk -F: '{print $1}')

# If group NAME doesn't exist, create it and assign it the group ID
if [[ -z "${DEVICE_GROUP_NAME}" ]]; then
DEVICE_GROUP_NAME="video${RANDOM}"
groupadd -g "${DEVICE_GROUP_ID}" "${DEVICE_GROUP_NAME}"
fi

# If the user hotio isn't a member of the group, add him
getent group "${DEVICE_GROUP_NAME}" | grep -q hotio || usermod -a -G "${DEVICE_GROUP_NAME}" hotio
done

######################
## Purge Codecs folder
if [[ "${PLEX_PURGE_CODECS}" == "true" ]]; then
echo "Purging Codecs folder..."
find "${CONFIG_DIR}/Codecs" -mindepth 1 -not -name '.device-id' -print -delete
fi

####################
## Install Plex Beta
[[ -n "${PLEX_PASS}" ]] && PLEX_BETA_INSTALL=${PLEX_PASS}
if [[ "${PLEX_BETA_INSTALL}" == "yes" ]] || [[ "${PLEX_BETA_INSTALL}" == "true" ]]; then
echo "Attempting beta installation..."
do_install=true

token="$(getPref "PlexOnlineToken")"
if [[ -z "${token}" ]]; then
echo "No token has been found! Aborting installation."
exit 0
do_install=false
fi

PLEX_PASS_VERSION=$(curl -fsSL "https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=${token}" | jq -r .computer.Linux.version)
PUBLIC_VERSION=$(curl -fsSL "https://plex.tv/api/downloads/5.json" | jq -r .computer.Linux.version)

if [[ "${PUBLIC_VERSION}" == "${PLEX_PASS_VERSION}" ]]; then
if [[ "${PUBLIC_VERSION}" == "${PLEX_PASS_VERSION}" ]] && [[ "${do_install}" == true ]]; then
echo "No eligable beta found! Aborting installation."
exit 0
do_install=false
fi

INSTALLED_VERSION=$(cat "${APP_DIR}/version")
if [[ "${INSTALLED_VERSION}" == "${PLEX_PASS_VERSION}" ]]; then
if [[ "${INSTALLED_VERSION}" == "${PLEX_PASS_VERSION}" ]] && [[ "${do_install}" == true ]]; then
echo "Already on the latest beta \"${PLEX_PASS_VERSION}\", no update required. Aborting installation."
exit 0
do_install=false
fi

case "${BUILD_ARCHITECTURE}" in
linux-amd64)
architecture="amd64"
;;
linux-arm64)
architecture="arm64"
;;
esac

debfile="/tmp/plex.deb" && curl -fsSL -o "${debfile}" "https://downloads.plex.tv/plex-media-server-new/${PLEX_PASS_VERSION}/debian/plexmediaserver_${PLEX_PASS_VERSION}_${architecture}.deb" && dpkg -i --force-confold "${debfile}" && rm -f "${debfile}" && echo "${PLEX_PASS_VERSION}" > "${APP_DIR}/version" && INSTALL_OK="yes"
if [[ "${INSTALL_OK}" != "yes" ]]; then
echo -e '\e[31m'"Installation of beta \"${PLEX_PASS_VERSION}\" failed!"'\e[0m'
exit 1
else
echo "Installation of beta \"${PLEX_PASS_VERSION}\" succeeded."
if [[ "${do_install}" == true ]]; then
case "${BUILD_ARCHITECTURE}" in
linux-amd64)
architecture="amd64"
;;
linux-arm64)
architecture="arm64"
;;
esac

debfile="/tmp/plex.deb" && \
curl -fsSL "https://downloads.plex.tv/plex-media-server-new/${PLEX_PASS_VERSION}/debian/plexmediaserver_${PLEX_PASS_VERSION}_${architecture}.deb" -o "${debfile}" && \
rm -rf "${APP_DIR:?}/bin" && \
mkdir "${APP_DIR}/bin" && \
dpkg-deb -x "${debfile}" "${APP_DIR}/bin" && \
rm -f "${debfile}" && \
echo "${PLEX_PASS_VERSION}" > "${APP_DIR}/version" && \
INSTALL_OK="yes"
if [[ "${INSTALL_OK}" != "yes" ]]; then
echo -e '\e[31m'"Installation of beta \"${PLEX_PASS_VERSION}\" failed!"'\e[0m'
exit 1
else
echo "Installation of beta \"${PLEX_PASS_VERSION}\" succeeded."
fi
fi
fi

Expand All @@ -169,37 +205,18 @@ INSTALLED_VERSION=$(cat "${APP_DIR}/version")
if [[ "${PLEX_BETA_INSTALL}" == "http"* ]] && [[ "${PLEX_BETA_INSTALL}" != "${INSTALLED_VERSION}" ]]; then
echo "Attempting custom installation...don't come crying for support!"

debfile="/tmp/plex.deb" && curl -fsSL -o "${debfile}" "${PLEX_BETA_INSTALL}" && dpkg -i --force-confold "${debfile}" && rm -f "${debfile}" && echo "${PLEX_BETA_INSTALL}" > "${APP_DIR}/version" && INSTALL_OK="yes"
debfile="/tmp/plex.deb" && \
curl -fsSL "${PLEX_BETA_INSTALL}" -o "${debfile}" && \
rm -rf "${APP_DIR:?}/bin" && \
mkdir "${APP_DIR}/bin" && \
dpkg-deb -x "${debfile}" "${APP_DIR}/bin" && \
rm -f "${debfile}" && \
echo "${PLEX_BETA_INSTALL}" > "${APP_DIR}/version" && \
INSTALL_OK="yes"
if [[ "${INSTALL_OK}" != "yes" ]]; then
echo -e '\e[31m'"Installation of \"${PLEX_BETA_INSTALL}\" failed!"'\e[0m'
exit 1
else
echo "Installation of \"${PLEX_BETA_INSTALL}\" succeeded."
fi
fi

#############
## HW Support
DEVICES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)

for i in ${DEVICES}; do
# Get the group ID and NAME (if exists) for the current device in the list
DEVICE_GROUP_ID=$(stat -c '%g' "$i")
DEVICE_GROUP_NAME=$(getent group "${DEVICE_GROUP_ID}" | awk -F: '{print $1}')

# If group NAME doesn't exist, create it and assign it the group ID
if [[ -z "${DEVICE_GROUP_NAME}" ]]; then
DEVICE_GROUP_NAME="video${RANDOM}"
groupadd -g "${DEVICE_GROUP_ID}" "${DEVICE_GROUP_NAME}"
fi

# If the user hotio isn't a member of the group, add him
getent group "${DEVICE_GROUP_NAME}" | grep -q hotio || usermod -a -G "${DEVICE_GROUP_NAME}" hotio
done

######################
## Purge Codecs folder
if [[ "${PLEX_PURGE_CODECS}" == "true" ]]; then
echo "Purging Codecs folder..."
find "${CONFIG_DIR}/Codecs" -mindepth 1 -not -name '.device-id' -print -delete
fi
18 changes: 9 additions & 9 deletions root/etc/s6-overlay/s6-rc.d/service-plex/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

umask "${UMASK}"

PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${APP_DIR}/config" && export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
TMPDIR="/transcode" && export TMPDIR
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" && export PLEX_MEDIA_SERVER_HOME
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 && export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" && export PLEX_MEDIA_SERVER_INFO_VENDOR
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (hotio)" && export PLEX_MEDIA_SERVER_INFO_DEVICE
PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" && export PLEX_MEDIA_SERVER_INFO_MODEL
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(uname -r)" && export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${APP_DIR}/config" && export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
TMPDIR="/transcode" && export TMPDIR
PLEX_MEDIA_SERVER_HOME="${APP_DIR}/bin/usr/lib/plexmediaserver" && export PLEX_MEDIA_SERVER_HOME
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6 && export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" && export PLEX_MEDIA_SERVER_INFO_VENDOR
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (hotio)" && export PLEX_MEDIA_SERVER_INFO_DEVICE
PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" && export PLEX_MEDIA_SERVER_INFO_MODEL
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(uname -r)" && export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION

echo -e '\n##################################\n## IGNORE THE ERROR MESSAGE: ##\n## Critical: libusb_init failed ##\n##################################\n'
exec s6-setuidgid hotio "/usr/lib/plexmediaserver/Plex Media Server"
exec s6-setuidgid hotio "${APP_DIR}/bin/usr/lib/plexmediaserver/Plex Media Server"

0 comments on commit 5fc1431

Please sign in to comment.