diff --git a/.drone.star b/.drone.star new file mode 100644 index 0000000..4f60b86 --- /dev/null +++ b/.drone.star @@ -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 diff --git a/.drone.yml b/.drone.yml deleted file mode 100644 index 9387135..0000000 --- a/.drone.yml +++ /dev/null @@ -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 - -... diff --git a/Dockerfile b/Dockerfile index a5d5e30..10d1482 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ ARG PLEX_VER=1.27.0.5897-3940636f2 -ARG PLEX_SHA=6f40a2fb51c04180a465dbbb8c463e0ac7f73dfb -ARG BUSYBOX_VER=1.34.1 +ARG BUSYBOX_VER=1.35.0 ARG SU_EXEC_VER=0.4 ARG TINI_VER=0.19.0 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 \ autoconf \ @@ -43,36 +42,39 @@ RUN apk add --no-cache \ FROM builder AS plex ARG PLEX_VER -ARG PLEX_SHA ARG OUTPUT WORKDIR $OUTPUT # 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 \ - && echo "$PLEX_SHA plexmediaserver.deb" | sha1sum -c - \ +RUN if [ "$(uname -m)" = "aarch64" ]; then \ + 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 . \ \ - && rm -r \ + && rm -rfv \ etc/ usr/share/ \ + usr/lib/plexmediaserver/etc \ plexmediaserver.deb \ \ && cd usr/lib/plexmediaserver \ - && rm \ + && rm -v \ lib/libcrypto.so* \ lib/libcurl.so* \ lib/libssl.so* \ lib/libnghttp2.so* \ lib/plexmediaserver.* \ - etc/ld-musl-x86_64.path \ Resources/start.sh \ \ # Place shared libraries in usr/lib so they can be actually shared - && mv lib/*.so* lib/dri ../ \ - && rmdir lib etc \ + && mv lib/*.so* $LIB_DIRS ../ \ + && rmdir lib \ && ln -sv ../ lib \ # 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 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/entrypoint b/entrypoint index 80455d2..fc838e7 100755 --- a/entrypoint +++ b/entrypoint @@ -35,7 +35,7 @@ if su-exec -e [ ! -w "$CONFIG_DIR" ]; then 2>&1 echo -e "${RED}#######################################################${RESET}" 2>&1 echo - chown $SUID:$SGID "$CONFIG_DIR" + chown "$SUID:$SGID" "$CONFIG_DIR" chmod o+rw "$CONFIG_DIR" fi @@ -44,11 +44,11 @@ export PREF_FILE="$CONFIG_DIR/Preferences.xml" exec su-exec -e sh <\n' > "${PREF_FILE}" +printf "\n" > "${PREF_FILE}" # Enforced defaults. These can be changed manually afterwards. setPref "EnableIPv6" "1" @@ -23,7 +23,7 @@ if [ -z "${serial}" ]; then fi clientId="$(getPref "ProcessedMachineIdentifier")" 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}" fi @@ -31,6 +31,6 @@ fi # It can also be triggered manually at any time by running # $ claim-server.sh --load-client-id --save -test -n "${ADVERTISE_IP}" && setPref "customConnections" "${ADVERTISE_IP}" -test -n "${ALLOWED_NETWORKS}" && setPref "allowedNetworks" "${ALLOWED_NETWORKS}" -test -n "${DISABLE_REMOTE_SEC}" && setPref "disableRemoteSecurity" "1" +if [ -n "${ADVERTISE_IP}" ]; then setPref "customConnections" "${ADVERTISE_IP}"; fi +if [ -n "${ALLOWED_NETWORKS}" ]; then setPref "allowedNetworks" "${ALLOWED_NETWORKS}"; fi +if [ -n "${DISABLE_REMOTE_SEC}" ]; then setPref "disableRemoteSecurity" "1"; fi diff --git a/plex-util.sh b/plex-util.sh index 3d560af..0c8364c 100644 --- a/plex-util.sh +++ b/plex-util.sh @@ -6,7 +6,7 @@ getPref() { } setPref() { 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 else xmlstarlet ed --inplace --insert "/Preferences" --type attr -n "$1" -v "$2" "${PREF_FILE}" 2>/dev/null