2
0
mirror of https://github.com/spritsail/plex-media-server.git synced 2024-12-20 11:34:36 +00:00

Build multiarch amd64/arm64 Plex images

Signed-off-by: Adam Dodman <adam@adam-ant.co.uk>
Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2022-06-19 16:02:00 +01:00
parent df4df5818b
commit 2c2269742a
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
6 changed files with 152 additions and 96 deletions

128
.drone.star Normal file
View File

@ -0,0 +1,128 @@
repo = "spritsail/plex-media-server"
architectures = ["amd64", "arm64"]
publish_branches = ["master", "pass"]
def main(ctx):
builds = []
depends_on = []
for arch in architectures:
key = "build-%s" % arch
builds.append(step(arch, key))
depends_on.append(key)
if ctx.build.branch in publish_branches:
builds.append(publish(depends_on))
builds.append(update_readme())
return builds
def step(arch, key):
return {
"kind": "pipeline",
"name": key,
"platform": {
"os": "linux",
"arch": arch,
},
"steps": [
{
"name": "build",
"pull": "always",
"image": "spritsail/docker-build",
"settings": {
"make": "true",
},
},
{
"name": "test-bin",
"pull": "always",
"image": "spritsail/docker-test",
"settings": {
"run": "busybox && curl --version && xmlstarlet --version"
},
},
{
"name": "test",
"pull": "always",
"image": "spritsail/docker-test",
"settings": {
"curl": ":32400/identity",
"delay": 5,
"pipe": "xmlstarlet sel -t -v \"/MediaContainer/@version\" | grep -qw \"$(label io.spritsail.version.plex | cut -d- -f1)\"",
"retry": 10
},
},
{
"name": "publish",
"pull": "always",
"image": "spritsail/docker-publish",
"settings": {
"registry": {"from_secret": "registry_url"},
"login": {"from_secret": "registry_login"},
},
"when": {
"branch": publish_branches,
"event": ["push"],
},
},
],
}
def publish(depends_on):
return {
"kind": "pipeline",
"name": "publish-manifest",
"depends_on": depends_on,
"platform": {
"os": "linux",
},
"steps": [
{
"name": "publish",
"image": "spritsail/docker-multiarch-publish",
"pull": "always",
"settings": {
"tags": [
"latest",
"%label io.spritsail.version.plex | %remsuf [0-9a-f]+$ | %auto 2"
],
"src_registry": {"from_secret": "registry_url"},
"src_login": {"from_secret": "registry_login"},
"dest_repo": repo,
"dest_login": {"from_secret": "docker_login"},
},
"when": {
"branch": publish_branches,
"event": ["push"],
},
},
],
}
def update_readme():
return {
"kind": "pipeline",
"name": "update-readme",
"depends_on": [
"publish-manifest",
],
"steps": [
{
"name": "dockerhub-readme",
"pull": "always",
"image": "jlesage/drone-push-readme",
"settings": {
"repo": repo,
"username": {"from_secret": "docker_username"},
"password": {"from_secret": "docker_password"},
},
"when": {
"branch": publish_branches,
"event": ["push"],
},
},
],
}
# vim: ft=python sw=2

View File

@ -1,74 +0,0 @@
---
kind: pipeline
name: build-amd64
platform:
os: linux
arch: amd64
steps:
- name: build
pull: always
image: spritsail/docker-build
settings:
make: true
- name: test-bin
pull: always
image: spritsail/docker-test
settings:
run: |
busybox && \
curl --version && \
xmlstarlet --version
- name: test
pull: always
image: spritsail/docker-test
settings:
curl: :32400/identity
delay: 5
pipe: |
xmlstarlet sel -t -v "/MediaContainer/@version" |
grep -qw "$(label io.spritsail.version.plex | cut -d- -f1)"
retry: 10
- name: publish
pull: always
image: spritsail/docker-publish
settings:
repo: spritsail/plex-media-server
tags:
- latest
- "%label io.spritsail.version.plex | %remsuf [0-9a-f]+$ | %auto 2"
login: {from_secret: docker_login}
when:
branch:
- master
event:
- push
---
kind: pipeline
name: update-readme
steps:
- name: dockerhub-readme
pull: always
image: jlesage/drone-push-readme
settings:
username: {from_secret: docker_username}
password: {from_secret: docker_password}
repo: spritsail/plex-media-server
when:
branch:
- master
- pass
event:
- push
---
kind: signature
hmac: ee4c475518f6fddf4c2227fdee938a3e8d5c0a63e52fbab79f1133c8f5a2a91d
...

View File

@ -1,6 +1,5 @@
ARG PLEX_VER=1.27.0.5897-3940636f2 ARG PLEX_VER=1.27.0.5897-3940636f2
ARG PLEX_SHA=6f40a2fb51c04180a465dbbb8c463e0ac7f73dfb ARG BUSYBOX_VER=1.35.0
ARG BUSYBOX_VER=1.34.1
ARG SU_EXEC_VER=0.4 ARG SU_EXEC_VER=0.4
ARG TINI_VER=0.19.0 ARG TINI_VER=0.19.0
ARG ZLIB_VER=1.2.12 ARG ZLIB_VER=1.2.12
@ -18,7 +17,7 @@ ARG LDFLAGS="$CFLAGS -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FROM spritsail/alpine:3.15 AS builder FROM spritsail/alpine:3.16 AS builder
RUN apk add --no-cache \ RUN apk add --no-cache \
autoconf \ autoconf \
@ -43,36 +42,39 @@ RUN apk add --no-cache \
FROM builder AS plex FROM builder AS plex
ARG PLEX_VER ARG PLEX_VER
ARG PLEX_SHA
ARG OUTPUT ARG OUTPUT
WORKDIR $OUTPUT WORKDIR $OUTPUT
# Fetch Plex and required libraries # Fetch Plex and required libraries
RUN curl -fsSL -o plexmediaserver.deb https://downloads.plex.tv/plex-media-server-new/${PLEX_VER}/debian/plexmediaserver_${PLEX_VER}_amd64.deb \ RUN if [ "$(uname -m)" = "aarch64" ]; then \
&& echo "$PLEX_SHA plexmediaserver.deb" | sha1sum -c - \ ARCH=arm64; LIB_DIRS=lib/omx; \
else \
ARCH=amd64; LIB_DIRS=lib/dri; \
fi \
&& curl -fsSL -o plexmediaserver.deb https://downloads.plex.tv/plex-media-server-new/${PLEX_VER}/debian/plexmediaserver_${PLEX_VER}_${ARCH}.deb \
&& dpkg-deb -x plexmediaserver.deb . \ && dpkg-deb -x plexmediaserver.deb . \
\ \
&& rm -r \ && rm -rfv \
etc/ usr/share/ \ etc/ usr/share/ \
usr/lib/plexmediaserver/etc \
plexmediaserver.deb \ plexmediaserver.deb \
\ \
&& cd usr/lib/plexmediaserver \ && cd usr/lib/plexmediaserver \
&& rm \ && rm -v \
lib/libcrypto.so* \ lib/libcrypto.so* \
lib/libcurl.so* \ lib/libcurl.so* \
lib/libssl.so* \ lib/libssl.so* \
lib/libnghttp2.so* \ lib/libnghttp2.so* \
lib/plexmediaserver.* \ lib/plexmediaserver.* \
etc/ld-musl-x86_64.path \
Resources/start.sh \ Resources/start.sh \
\ \
# Place shared libraries in usr/lib so they can be actually shared # Place shared libraries in usr/lib so they can be actually shared
&& mv lib/*.so* lib/dri ../ \ && mv lib/*.so* $LIB_DIRS ../ \
&& rmdir lib etc \ && rmdir lib \
&& ln -sv ../ lib \ && ln -sv ../ lib \
# Replace hardlink with a symlink; these files are the same # Replace hardlink with a symlink; these files are the same
&& cd .. && ln -sfvn ld-musl-x86_64.so.1 libc.so && cd .. && ln -sfvn "ld-musl-$(uname -m).so.1" libc.so
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -35,7 +35,7 @@ if su-exec -e [ ! -w "$CONFIG_DIR" ]; then
2>&1 echo -e "${RED}#######################################################${RESET}" 2>&1 echo -e "${RED}#######################################################${RESET}"
2>&1 echo 2>&1 echo
chown $SUID:$SGID "$CONFIG_DIR" chown "$SUID:$SGID" "$CONFIG_DIR"
chmod o+rw "$CONFIG_DIR" chmod o+rw "$CONFIG_DIR"
fi fi
@ -44,11 +44,11 @@ export PREF_FILE="$CONFIG_DIR/Preferences.xml"
exec su-exec -e sh <<EOF exec su-exec -e sh <<EOF
source plex-util.sh . plex-util.sh
# Generate a default configuration on first run, including some user-specified values # Generate a default configuration on first run, including some user-specified values
if [ ! -e "\$PREF_FILE" ]; then if [ ! -e "\$PREF_FILE" ]; then
source gen-config.sh . gen-config.sh
fi fi
# Changes the log verbosity (Environment variable takes precedence on Plex Config) # Changes the log verbosity (Environment variable takes precedence on Plex Config)

View File

@ -2,10 +2,10 @@
set -e set -e
# Contains getPref/setPref and PREF_FILE vars # Contains getPref/setPref and PREF_FILE vars
source plex-util.sh . plex-util.sh
# Create a default config file allowing external access # Create a default config file allowing external access
echo -e $'<?xml version="1.0" encoding="utf-8"?>\n<Preferences />' > "${PREF_FILE}" printf "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Preferences />" > "${PREF_FILE}"
# Enforced defaults. These can be changed manually afterwards. # Enforced defaults. These can be changed manually afterwards.
setPref "EnableIPv6" "1" setPref "EnableIPv6" "1"
@ -23,7 +23,7 @@ if [ -z "${serial}" ]; then
fi fi
clientId="$(getPref "ProcessedMachineIdentifier")" clientId="$(getPref "ProcessedMachineIdentifier")"
if [ -z "${clientId}" ]; then if [ -z "${clientId}" ]; then
clientId="$(echo -n "${serial}- Plex Media Server" | sha1sum | cut -b 1-40)" clientId="$(printf %s "${serial}- Plex Media Server" | sha1sum | cut -b 1-40)"
setPref "ProcessedMachineIdentifier" "${clientId}" setPref "ProcessedMachineIdentifier" "${clientId}"
fi fi
@ -31,6 +31,6 @@ fi
# It can also be triggered manually at any time by running # It can also be triggered manually at any time by running
# $ claim-server.sh --load-client-id --save # $ claim-server.sh --load-client-id --save
test -n "${ADVERTISE_IP}" && setPref "customConnections" "${ADVERTISE_IP}" if [ -n "${ADVERTISE_IP}" ]; then setPref "customConnections" "${ADVERTISE_IP}"; fi
test -n "${ALLOWED_NETWORKS}" && setPref "allowedNetworks" "${ALLOWED_NETWORKS}" if [ -n "${ALLOWED_NETWORKS}" ]; then setPref "allowedNetworks" "${ALLOWED_NETWORKS}"; fi
test -n "${DISABLE_REMOTE_SEC}" && setPref "disableRemoteSecurity" "1" if [ -n "${DISABLE_REMOTE_SEC}" ]; then setPref "disableRemoteSecurity" "1"; fi

View File

@ -6,7 +6,7 @@ getPref() {
} }
setPref() { setPref() {
count="$(xmlstarlet sel -t -v "count(/Preferences/@$1)" "${PREF_FILE}")" count="$(xmlstarlet sel -t -v "count(/Preferences/@$1)" "${PREF_FILE}")"
if [ $(($count + 0)) -gt 0 ]; then if [ $((count + 0)) -gt 0 ]; then
xmlstarlet ed --inplace --update "/Preferences/@$1" -v "$2" "${PREF_FILE}" 2>/dev/null xmlstarlet ed --inplace --update "/Preferences/@$1" -v "$2" "${PREF_FILE}" 2>/dev/null
else else
xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "$1" -v "$2" "${PREF_FILE}" 2>/dev/null xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "$1" -v "$2" "${PREF_FILE}" 2>/dev/null