Docker: Add S6 overlay to base images for process supervision #4767

see https://skarnet.org/software/s6/

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-02-04 18:21:35 +01:00
parent 8b41d67ec0
commit 7ff6b384a2
5 changed files with 93 additions and 3 deletions

View File

@@ -13,6 +13,7 @@
/photoprism-*
/coverage.*
/frontend/tests/acceptance/screenshots
/test/
# Custom config, database, log, and temporary files
/tmp/

1
.gitignore vendored
View File

@@ -10,6 +10,7 @@
/assets/nasnet
/assets/nsfw
/assets/static/build/
/test/
/pro
/plus
*.exe

View File

@@ -637,18 +637,34 @@ stop-mysql:
$(DOCKER_COMPOSE) -f compose.mysql.yaml stop mysql
logs-mysql:
$(DOCKER_COMPOSE) -f compose.mysql.yaml logs -f mysql
latest:
test-latest:
$(DOCKER_COMPOSE) -f compose.latest.yaml pull photoprism-latest
$(DOCKER_COMPOSE) -f compose.latest.yaml stop photoprism-latest
$(DOCKER_COMPOSE) -f compose.latest.yaml up -d --wait photoprism-latest
start-latest:
$(DOCKER_COMPOSE) -f compose.latest.yaml up photoprism-latest
stop-latest:
$(DOCKER_COMPOSE) -f compose.latest.yaml stop photoprism-latest
$(DOCKER_COMPOSE) -f compose.latest.yaml stop -t 30 photoprism-latest
down-latest:
$(DOCKER_COMPOSE) -f compose.latest.yaml down -t 30 photoprism-latest
terminal-latest:
$(DOCKER_COMPOSE) -f compose.latest.yaml exec photoprism-latest bash
logs-latest:
$(DOCKER_COMPOSE) -f compose.latest.yaml logs -f photoprism-latest
test-preview:
$(DOCKER_COMPOSE) -f compose.preview.yaml pull photoprism-preview
$(DOCKER_COMPOSE) -f compose.preview.yaml stop photoprism-preview
$(DOCKER_COMPOSE) -f compose.preview.yaml up -d --wait photoprism-preview
start-preview:
$(DOCKER_COMPOSE) -f compose.preview.yaml up photoprism-preview
stop-preview:
$(DOCKER_COMPOSE) -f compose.preview.yaml stop -t 30 photoprism-preview
down-preview:
$(DOCKER_COMPOSE) -f compose.preview.yaml down -t 30 photoprism-preview
terminal-preview:
$(DOCKER_COMPOSE) -f compose.preview.yaml exec photoprism-preview bash
logs-preview:
$(DOCKER_COMPOSE) -f compose.preview.yaml logs -f photoprism-preview
docker-local: docker-local-oracular
docker-local-all: docker-local-oracular docker-local-noble docker-local-mantic docker-local-lunar docker-local-jammy docker-local-bookworm docker-local-bullseye docker-local-buster
docker-local-bookworm:

View File

@@ -31,7 +31,9 @@ ENV PHOTOPRISM_ARCH=$TARGETARCH \
DEBIAN_FRONTEND="noninteractive" \
TF_CPP_MIN_LOG_LEVEL="2" \
MALLOC_ARENA_MAX="4" \
PROG="photoprism"
PROG="photoprism" \
S6_KEEP_ENV=1 \
S6_LOGGING=0
# Copy scripts and package sources config.
COPY --chown=root:root --chmod=755 /scripts/dist/ /scripts/
@@ -69,6 +71,7 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/photoprism/storage/backups \
/photoprism/storage/config \
/photoprism/storage/cache && \
/scripts/install-s6.sh && \
/scripts/cleanup.sh
# Default working directory.

69
scripts/dist/install-s6.sh vendored Executable file
View File

@@ -0,0 +1,69 @@
#!/usr/bin/env bash
# This downloads and installs the s6-overlay binaries and noarch files from GitHub.
#
# Show usage information if first argument is --help.
if [[ ${1} == "--help" ]]; then
echo "Usage: ${0##*/} [version] [dir]" 1>&2
exit 0
fi
# You can provide a custom installation directory as the first argument.
S6_OVERLAY_DESTDIR=$(realpath "${2:-/}")
# Determine the system architecture.
if [[ $PHOTOPRISM_ARCH ]]; then
SYSTEM_ARCH=$PHOTOPRISM_ARCH
else
SYSTEM_ARCH=$(uname -m)
fi
. /etc/os-release
S6_OVERLAY_ARCH=${BUILD_ARCH:-$SYSTEM_ARCH}
case $S6_OVERLAY_ARCH in
amd64 | AMD64 | x86_64 | x86-64)
S6_OVERLAY_ARCH=x86_64
;;
arm64 | ARM64 | aarch64)
S6_OVERLAY_ARCH=aarch64
;;
arm | ARM | aarch | armv7l | armhf)
S6_OVERLAY_ARCH=armhf
;;
*)
echo "Unsupported Machine Architecture: \"$S6_OVERLAY_ARCH\"" 1>&2
exit 1
;;
esac
set -eu
S6_OVERLAY_LATEST=$(curl --silent "https://api.github.com/repos/just-containers/s6-overlay/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
S6_OVERLAY_VERSION=${1:-$S6_OVERLAY_LATEST}
S6_ARCH_URL="https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz"
S6_NOARCH_URL="https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz"
echo "Installing S6 Overlay..."
echo "------------------------------------------------"
echo "VERSION : ${S6_OVERLAY_VERSION}"
echo "LATEST : ${S6_OVERLAY_LATEST}"
echo "DESTDIR : ${S6_OVERLAY_DESTDIR}"
echo "BINARY URL: ${S6_ARCH_URL}"
echo "NOARCH URL: ${S6_NOARCH_URL}"
echo "------------------------------------------------"
echo "Extracting \"$S6_ARCH_URL\" to \"$S6_OVERLAY_DESTDIR\"."
sudo mkdir -p "${S6_OVERLAY_DESTDIR}"
wget --inet4-only -c "$S6_ARCH_URL" -O - | sudo tar -C "${S6_OVERLAY_DESTDIR}" -Jxp
echo "Extracting \"$S6_NOARCH_URL\" to \"$S6_OVERLAY_DESTDIR\"."
sudo mkdir -p "${S6_OVERLAY_DESTDIR}"
wget --inet4-only -c "$S6_NOARCH_URL" -O - | sudo tar -C "${S6_OVERLAY_DESTDIR}" -Jxp
echo "Done."