-
Notifications
You must be signed in to change notification settings - Fork 552
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
"Autoupdate" feature. Update S6. Shellcheck. #81
base: master
Are you sure you want to change the base?
Changes from 1 commit
156169f
a09c55b
63c3c8c
b0ae80d
d504440
c5f4f70
c5da1c4
83062cd
502203f
42fdfc9
709a6de
e2734a5
c2fad2c
2cae64a
fcd1c43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ FROM ubuntu:22.04 as base-amd64 | |
ARG S6_OVERLAY_VERSION=v3.1.5.0 | ||
ARG S6_OVERLAY_ARCH=x86_64 | ||
ARG PLEX_BUILD=linux-x86_64 | ||
ARG PLEX_DISTRO=debian | ||
ARG INTEL_NEO_VERSION=20.48.18558 | ||
ARG INTEL_IGC_VERSION=1.0.5699 | ||
ARG INTEL_GMMLIB_VERSION=20.3.2 | ||
|
@@ -71,17 +70,18 @@ RUN \ | |
EXPOSE 32400/tcp 8324/tcp 32469/tcp 1900/udp 32410/udp 32412/udp 32413/udp 32414/udp | ||
VOLUME /config /transcode | ||
|
||
ARG AUTOUPDATE=false | ||
ARG TAG=beta | ||
# TAG can be "autoupdate" or an explicit version, like 1.32.4.7195-7c8f9d3b6 | ||
ARG TAG="autoupdate" | ||
ARG URL= | ||
ARG DEBUG= | ||
|
||
ENV TAG=${TAG} \ | ||
CHANGE_CONFIG_DIR_OWNERSHIP="true" \ | ||
ENV CHANGE_CONFIG_DIR_OWNERSHIP="true" \ | ||
HOME="/config" \ | ||
TZ="UTC" \ | ||
# Note, only used for images built with TAG=autoupdate | ||
AUTO_UPDATE_CHANNEL="beta" \ | ||
\ | ||
TERM="xterm" \ | ||
LANG="C.UTF-8" \ | ||
TERM="xterm" \ | ||
LANG="C.UTF-8" \ | ||
LC_ALL="C.UTF-8" \ | ||
\ | ||
S6_KEEP_ENV=1 \ | ||
|
@@ -94,8 +94,11 @@ COPY root/ / | |
|
||
RUN \ | ||
# Save version and install | ||
/installBinary.sh | ||
/installBinary.sh \ | ||
&& \ | ||
# Clean up installer | ||
rm /installBinary.sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this intended to cleanup a deb file instead of removing the script to install debs? |
||
|
||
HEALTHCHECK --interval=5s --timeout=2s --retries=20 CMD /healthcheck.sh || exit 1 | ||
|
||
ENTRYPOINT ["/init"] | ||
ENTRYPOINT ["/init"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,45 @@ | ||
# Dev Helper Scripts | ||
|
||
Unless you are making changes to the Dockerfile themselves, please ignore all the files here. In fact, your environment may be very different and these scripts may not work at all. They are provided only as a reference/starting point so you don't have to start from scratch. Heavy customizations are likely. | ||
Hey homelab enthusiast! | ||
|
||
Unless you are enhancing these Dockerfile themselves, please ignore all the files here. In fact, your environment may be very different and these scripts may not work at all. These are just provided only as a reference/starting point so you don't have to start from scratch. | ||
|
||
You might just consider extending the images here. i.e. | ||
|
||
``` | ||
FROM plexinc/pms-docker:latest | ||
|
||
RUN echo "Add your modifications here" | ||
``` | ||
|
||
Otherwise, `dev.sh` will build all of the multi-platform docker images, for each platform it will build one that uses a specific version, and `autoupdate` version that doesn't bake the binary into the image, but rather downloads when container boots. Look inside the script for more info. | ||
|
||
`docker-bake.hcl` is a buildx bake file that will build all platforms, using pre-installed binaries and `update` versions. This bake file will push to dockerhub. You can override the destination using the `dockerhub_image` variable in `dev.sh`. | ||
|
||
|
||
### Examples | ||
|
||
#### Prereqs: | ||
- [docker](https://docs.docker.com/engine/install/) | ||
- [buildx](https://github.com/docker/buildx) | ||
- x86 based linux host | ||
|
||
```sh | ||
# sets up buildx for multi-arch builds | ||
./dev.sh setup | ||
|
||
# bake - build all and push to dockerhub | ||
./dev.sh bake | ||
|
||
# build version-specific and autoupdate image for amd64 | ||
./dev.sh build amd64 | ||
|
||
# build everything | ||
./dev.sh buildall | ||
|
||
# launches version-specific container | ||
./dev.sh debug amd64 | ||
|
||
# launches auto-update container | ||
./dev.sh debug amd64 autoupdate | ||
``` |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
# This is just a helper script to quickly test local Dockerfile builds, please run setup() once | ||
# Assumes this is running on Linux (any distro) using (intel/amd). | ||
|
||
# This bakes the specific binary into the image, you can override these vars on command line | ||
# DOCKERHUB_IMAGE=myorg/mycontainer ./dev/sh bake | ||
VERSION_TO_BUILD=${VERSION_TO_BUILD:-"1.32.4.7195-7c8f9d3b6"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure it should default to a particular version as this script is likely not to be updated often as the server advances in version. |
||
DOCKERHUB_IMAGE=${DOCKERHUB_IMAGE:-"plexinc/pms-docker"} | ||
|
||
setup() { | ||
# Create a multi-arch buildx builder named PlexBuilder (if it doesn't exist) | ||
if ! docker buildx inspect PlexBuilder 1> /dev/null 2>& 1; then | ||
echo Creating PlexBuilder | ||
# --use will make it automatically use this builder | ||
docker buildx create --name PlexBuilder --platform linux/arm64,linux/arm/v7,linux/386 --use | ||
# this is needed to register the arch-specific images with QEMU to be able to test | ||
# these without native hardware | ||
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes | ||
fi | ||
} | ||
build() { | ||
platform=$1 | ||
name=$2 | ||
docker buildx build \ | ||
--progress=plain \ | ||
-o type=docker \ | ||
--load \ | ||
--platform "$platform" \ | ||
--build-arg \ | ||
"TAG=$VERSION_TO_BUILD" \ | ||
-t "$name:$VERSION_TO_BUILD" \ | ||
-t "$name:latest" \ | ||
-f ../Dockerfile .. | ||
docker buildx build \ | ||
--progress=plain \ | ||
-o type=docker \ | ||
--load \ | ||
--platform "$platform" \ | ||
--build-arg \ | ||
"TAG=autoupdate" \ | ||
-t "$name:autoupdate" \ | ||
-f ../Dockerfile .. | ||
} | ||
|
||
debug() { | ||
platform=$1 | ||
name=$2 | ||
autoupdate=$3 | ||
if [ "$autoupdate" = "autoupdate" ]; then | ||
name=$name:autoupdate | ||
else | ||
name=$name:latest | ||
fi | ||
if [[ $platform == linux/arm* ]]; then | ||
# shellcheck disable=SC2064 | ||
trap "trap - SIGTERM && docker stop debug-plex" SIGINT SIGTERM EXIT | ||
docker run --rm --name debug-plex --platform "$platform" -e DEBUG=true "$name" & | ||
sleep 5 | ||
docker exec -it debug-plex bash | ||
else | ||
docker run --rm --name debug-plex --platform "$platform" -e DEBUG=true -it "$name" bash | ||
fi | ||
} | ||
|
||
cmd=${1:-} | ||
kind=${2:-} | ||
[ "$cmd" = 'setup' ] && setup | ||
[ "$cmd" = 'build' ] && [ "$kind" = '386' ] && build linux/386 pms-386 | ||
[ "$cmd" = 'build' ] && [ "$kind" = 'amd64' ] && build linux/amd64 pms-amd64 | ||
[ "$cmd" = 'build' ] && [ "$kind" = 'arm32v7' ] && build linux/arm/v7 pms-arm32v7 | ||
[ "$cmd" = 'build' ] && [ "$kind" = 'arm64v8' ] && build linux/arm64 pms-arm64v8 | ||
[ "$cmd" = 'buildall' ] && \ | ||
build linux/386 pms-386 && \ | ||
build linux/amd64 pms-amd64 && \ | ||
build linux/arm/v7 pms-arm32v7 && \ | ||
build linux/arm64 pms-arm64v8 | ||
|
||
[ "$cmd" = 'bake' ] && TAG=$VERSION_TO_BUILD IMAGE=$DOCKERHUB_IMAGE docker buildx bake | ||
|
||
autoupdate=${3:-} | ||
[ "$cmd" = 'debug' ] && [ "$kind" = '386' ] && debug linux/386 pms-386 "$autoupdate" | ||
[ "$cmd" = 'debug' ] && [ "$kind" = 'amd64' ] && debug linux/amd64 pms-amd64 "$autoupdate" | ||
[ "$cmd" = 'debug' ] && [ "$kind" = 'arm32v7' ] && debug linux/arm/v7 pms-arm32v7 "$autoupdate" | ||
[ "$cmd" = 'debug' ] && [ "$kind" = 'arm64v8' ] && debug linux/arm64 pms-arm64v8 "$autoupdate" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# run this file using "docker buildx bake" | ||
|
||
variable "TAG" { | ||
# This should be overridden on command line to be the | ||
# specific plex media server binary to download into the image | ||
default = "1.32.4.7195-7c8f9d3b6" | ||
} | ||
variable "IMAGE" { | ||
default = "plexinc/pms-docker" | ||
} | ||
|
||
group "default" { | ||
targets = ["plexmediaserver-versioned", "plexmediaserver-autoupdate"] | ||
} | ||
|
||
target "plexmediaserver-versioned" { | ||
# This target builds targets that downloald and pre-install the | ||
# the plex media server binary in the container. This image | ||
# has two tags, the version itself, and assuming this is that latest | ||
# also tags it with :latest. | ||
output = ["type=registry"] | ||
context = ".." | ||
platforms = ["linux/386", "linux/amd64", "linux/arm64", "linux/arm/v7"] | ||
tags = ["${IMAGE}:${TAG}", "${IMAGE}:latest"] | ||
args = { | ||
TAG = "${TAG}" | ||
} | ||
} | ||
target "plexmediaserver-autoupdate" { | ||
# This target build a download and pre-install a configuration of the | ||
# container automatically downloads and installs the server at runtime | ||
# and automatically checks for updates once a day. | ||
output = ["type=registry"] | ||
context = ".." | ||
platforms = ["linux/386", "linux/amd64", "linux/arm64", "linux/arm/v7"] | ||
tags = ["${IMAGE}:autoupdate"] | ||
args = { | ||
TAG = "autoupdate" | ||
} | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not certain about making the auto update the default behavior. It is antithetical to docker but then so is the current default of beta so 🤷 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I made this comment, I didn't realize that your work is effectively supplanting the public and beta tags. So, assuming that I have that correct, then this change isn't really a change.