2
0
mirror of https://github.com/spritsail/plex-media-server.git synced 2025-06-25 19:30:55 +00:00

Build Plex on musl, from scratch

Plex now provide a first-party musl Plex build that works without any
external dependencies whatsoever. It's built with LLVM with many
compiler and linker optimisations enabled:
https://forums.plex.tv/t/plex-media-server-forum-preview-faster-and-smaller-builds-with-new-toolchain/699575

Restructure build into multiple distinct Docker build stages to better
leverage caching and significantly improve build time on multicore
systems with BuildKit, particularly with LTO enabled.

Changes for this release include:
- Build `FROM spritsail/alpine` instead of `FROM debian` to ensure musl
  compatibility with all compiled binaries. Use `FROM scratch` for the
  resulting image. ld-musl is provided by Plex.
- Build busybox, su-exec and tini as they're no longer provided by the
  base image.
- Build binaries/libraries with standard hardening flags, including the
  popular -flto.

Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
2021-05-28 11:12:19 +01:00
parent 48abfda1b6
commit f01f4950ab
4 changed files with 224 additions and 85 deletions

View File

@ -2,9 +2,9 @@
set -e
# Contains getPref/setPref and PREF_FILE vars
source plex-util.sh
. plex-util.sh
opts=`getopt -n "$0" -l save -l token: -l client-id: -l load-client-id -- st:c:l "$@"` || exit 1
opts=$(getopt -n "$0" -l save -l token: -l client-id: -l load-client-id -- st:c:l "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
@ -34,15 +34,16 @@ fi
>&2 echo "Attempting to obtain server token from claim token"
loginInfo="$(curl -X POST \
-H 'X-Plex-Client-Identifier: '${clientId} \
-H 'X-Plex-Product: Plex Media Server'\
-H 'X-Plex-Version: 1.1' \
-H 'X-Plex-Provides: server' \
-H 'X-Plex-Platform: Linux' \
-H 'X-Plex-Platform-Version: 1.0' \
-H 'X-Plex-Device-Name: PlexMediaServer' \
-H 'X-Plex-Device: Linux' \
"https://plex.tv/api/claim/exchange?token=${claimToken}")"
-H "X-Plex-Client-Identifier: ${clientId}" \
-H "X-Plex-Product: Plex Media Server" \
-H "X-Plex-Version: 1.1" \
-H "X-Plex-Provides: server" \
-H "X-Plex-Platform: Linux" \
-H "X-Plex-Platform-Version: 1.0" \
-H "X-Plex-Device-Name: PlexMediaServer" \
-H "X-Plex-Device: Linux" \
"https://plex.tv/api/claim/exchange?token=${claimToken}"
)"
authtoken="$(echo "$loginInfo" | sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p')"