From 09d2673099d281e0dc3e2308915226bd8d41fba6 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 29 Sep 2021 09:01:57 +0200 Subject: [PATCH] Docker: Install optional dependencies via PHOTOPRISM_INIT #536 #1337 --- Dockerfile | 1 + docker-compose.drone.yml | 1 + docker-compose.latest.yml | 1 + docker-compose.yml | 58 ++++++++++++-------- docker/development/Dockerfile | 11 ++-- docker/development/entrypoint.sh | 20 +++++-- docker/examples/arm64/docker-compose.yml | 5 +- docker/examples/cloud/digitalocean.json | 8 +-- docker/examples/cloud/docker-compose.yml | 2 + docker/examples/docker-compose.yml | 12 ++++ docker/examples/macos/docker-compose.yml | 2 + docker/examples/scheduler/docker-compose.yml | 2 + docker/examples/sqlite/docker-compose.yml | 2 + docker/examples/windows/docker-compose.yml | 1 + docker/photoprism/Dockerfile | 14 +++-- docker/{scripts => photoprism}/entrypoint.sh | 20 +++++-- docker/scripts/Makefile | 28 ++++++++++ docker/scripts/install-tensorflow.sh | 4 +- 18 files changed, 142 insertions(+), 50 deletions(-) rename docker/{scripts => photoprism}/entrypoint.sh (87%) create mode 100644 docker/scripts/Makefile diff --git a/Dockerfile b/Dockerfile index 4a5b5e8cf..1ee88f969 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM photoprism/development:20210928 # Copy latest entrypoint script COPY --chown=root:root /docker/development/entrypoint.sh /entrypoint.sh +COPY --chown=root:root /docker/scripts/Makefile /root/Makefile # Set up project directory WORKDIR "/go/src/github.com/photoprism/photoprism" diff --git a/docker-compose.drone.yml b/docker-compose.drone.yml index 9fbb66e56..6a0f4b381 100644 --- a/docker-compose.drone.yml +++ b/docker-compose.drone.yml @@ -40,6 +40,7 @@ services: PHOTOPRISM_STORAGE_PATH: "/go/src/github.com/photoprism/photoprism/storage" PHOTOPRISM_ORIGINALS_PATH: "/go/src/github.com/photoprism/photoprism/storage/originals" PHOTOPRISM_IMPORT_PATH: "/go/src/github.com/photoprism/photoprism/storage/import" + PHOTOPRISM_DISABLE_CHOWN: "true" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_BACKUPS: "false" # Don't backup photo and album metadata to YAML files PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI diff --git a/docker-compose.latest.yml b/docker-compose.latest.yml index 928201fda..f533d6b67 100644 --- a/docker-compose.latest.yml +++ b/docker-compose.latest.yml @@ -31,6 +31,7 @@ services: PHOTOPRISM_DATABASE_USER: "root" PHOTOPRISM_DATABASE_PASSWORD: "photoprism" PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # The initial admin password (min 4 characters) + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_BACKUPS: "false" # Don't backup photo and album metadata to YAML files PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI diff --git a/docker-compose.yml b/docker-compose.yml index 0661987f6..82e216d77 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,10 +13,6 @@ services: ports: - "2342:2342" # Web Server (PhotoPrism) - "2343:2343" # Acceptance Tests - working_dir: "/go/src/github.com/photoprism/photoprism" - volumes: - - ".:/go/src/github.com/photoprism/photoprism" - - "go-mod:/go/pkg/mod" shm_size: "2gb" environment: PHOTOPRISM_UID: ${UID:-1000} @@ -33,7 +29,7 @@ services: PHOTOPRISM_SERVER_MODE: "debug" PHOTOPRISM_HTTP_HOST: "0.0.0.0" PHOTOPRISM_HTTP_PORT: 2342 - PHOTOPRISM_HTTP_COMPRESSION: "gzip" # Improves transfer speed and bandwidth utilization (none or gzip) + PHOTOPRISM_HTTP_COMPRESSION: "gzip" # Improves transfer speed and bandwidth utilization (none or gzip) PHOTOPRISM_DATABASE_DRIVER: "mysql" PHOTOPRISM_DATABASE_SERVER: "mariadb:4001" PHOTOPRISM_DATABASE_NAME: "photoprism" @@ -41,28 +37,44 @@ services: PHOTOPRISM_DATABASE_PASSWORD: "photoprism" PHOTOPRISM_TEST_DRIVER: "sqlite" PHOTOPRISM_TEST_DSN: ".test.db" - PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # The initial admin password (min 4 characters) + PHOTOPRISM_ADMIN_PASSWORD: "photoprism" # The initial admin password (min 4 characters) PHOTOPRISM_ASSETS_PATH: "/go/src/github.com/photoprism/photoprism/assets" PHOTOPRISM_STORAGE_PATH: "/go/src/github.com/photoprism/photoprism/storage" PHOTOPRISM_ORIGINALS_PATH: "/go/src/github.com/photoprism/photoprism/storage/originals" PHOTOPRISM_IMPORT_PATH: "/go/src/github.com/photoprism/photoprism/storage/import" - PHOTOPRISM_DISABLE_BACKUPS: "false" # Don't backup photo and album metadata to YAML files - PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server - PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI - PHOTOPRISM_DISABLE_PLACES: "false" # Disables reverse geocoding and maps - PHOTOPRISM_DISABLE_EXIFTOOL: "false" # Don't create ExifTool JSON files for improved metadata extraction - PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Don't use TensorFlow for image classification - PHOTOPRISM_DETECT_NSFW: "false" # Flag photos as private that MAY be offensive (requires TensorFlow) - PHOTOPRISM_UPLOAD_NSFW: "false" # Allows uploads that may be offensive - PHOTOPRISM_DARKTABLE_PRESETS: "false" # Enables Darktable presets and disables concurrent RAW conversion - PHOTOPRISM_THUMB_FILTER: "lanczos" # Resample filter, best to worst: blackman, lanczos, cubic, linear - PHOTOPRISM_THUMB_UNCACHED: "true" # Enables on-demand thumbnail rendering (high memory and cpu usage) - PHOTOPRISM_THUMB_SIZE: 2048 # Pre-rendered thumbnail size limit (default 2048, min 720, max 7680) - # PHOTOPRISM_THUMB_SIZE: 4096 # Retina 4K, DCI 4K (requires more storage); 7680 for 8K Ultra HD - PHOTOPRISM_THUMB_SIZE_UNCACHED: 7680 # On-demand rendering size limit (default 7680, min 720, max 7680) - PHOTOPRISM_JPEG_SIZE: 7680 # Size limit for converted image files in pixels (720-30000) - PHOTOPRISM_JPEG_QUALITY: 92 # Set to 95 for high-quality thumbnails (25-100) - TF_CPP_MIN_LOG_LEVEL: 0 # Show TensorFlow log messages for development + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup + PHOTOPRISM_DISABLE_BACKUPS: "false" # Don't backup photo and album metadata to YAML files + PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server + PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI + PHOTOPRISM_DISABLE_PLACES: "false" # Disables reverse geocoding and maps + PHOTOPRISM_DISABLE_EXIFTOOL: "false" # Don't create ExifTool JSON files for improved metadata extraction + PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Don't use TensorFlow for image classification + PHOTOPRISM_DETECT_NSFW: "false" # Flag photos as private that MAY be offensive (requires TensorFlow) + PHOTOPRISM_UPLOAD_NSFW: "false" # Allows uploads that may be offensive + PHOTOPRISM_DARKTABLE_PRESETS: "false" # Enables Darktable presets and disables concurrent RAW conversion + PHOTOPRISM_THUMB_FILTER: "lanczos" # Resample filter, best to worst: blackman, lanczos, cubic, linear + PHOTOPRISM_THUMB_UNCACHED: "true" # Enables on-demand thumbnail rendering (high memory and cpu usage) + PHOTOPRISM_THUMB_SIZE: 2048 # Pre-rendered thumbnail size limit (default 2048, min 720, max 7680) + # PHOTOPRISM_THUMB_SIZE: 4096 # Retina 4K, DCI 4K (requires more storage); 7680 for 8K Ultra HD + PHOTOPRISM_THUMB_SIZE_UNCACHED: 7680 # On-demand rendering size limit (default 7680, min 720, max 7680) + PHOTOPRISM_JPEG_SIZE: 7680 # Size limit for converted image files in pixels (720-30000) + PHOTOPRISM_JPEG_QUALITY: 92 # Set to 95 for high-quality thumbnails (25-100) + TF_CPP_MIN_LOG_LEVEL: 0 # Show TensorFlow log messages for development + # Enable TensorFlow AVX2 support for modern Intel CPUs: + # PHOTOPRISM_INIT: "tensorflow-amd64-avx2" + # Hardware video transcoding options: + # PHOTOPRISM_FFMPEG_BUFFERS: "64" # FFmpeg capture buffers (default: 32) + # PHOTOPRISM_FFMPEG_ENCODER: "h264_v4l2m2m" # Use Video4Linux for AVC transcoding (default: libx264) + # PHOTOPRISM_FFMPEG_ENCODER: "h264_qsv" # Use Intel Quick Sync Video for AVC transcoding (default: libx264) + # PHOTOPRISM_INIT: "intel-graphics tensorflow-amd64-avx2" # Enable TensorFlow AVX2 & Intel Graphics support + # Optional hardware devices for video transcoding and machine learning: + # devices: + # - "/dev/video11:/dev/video11" # Video4Linux (h264_v4l2m2m) + # - "/dev/dri/renderD128:/dev/dri/renderD128" # Intel GPU + working_dir: "/go/src/github.com/photoprism/photoprism" + volumes: + - ".:/go/src/github.com/photoprism/photoprism" + - "go-mod:/go/pkg/mod" mariadb: image: mariadb:10.5 diff --git a/docker/development/Dockerfile b/docker/development/Dockerfile index f70468ec3..6c61c4e69 100644 --- a/docker/development/Dockerfile +++ b/docker/development/Dockerfile @@ -21,7 +21,7 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ COPY --chown=root:root --chmod=755 /docker/scripts/*.sh /root/.local/bin/ # Install dev / build dependencies -RUN apt-get update && apt dist-upgrade 2>/dev/null && apt-get -qq install -y --no-install-recommends \ +RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-install-recommends \ build-essential \ ca-certificates \ wget \ @@ -116,8 +116,11 @@ RUN rm -rf /tmp/* && mkdir -p /tmp/photoprism && \ wget "https://dl.photoprism.org/tensorflow/facenet.zip?${BUILD_TAG}" -O /tmp/photoprism/facenet.zip && \ wget "https://dl.photoprism.org/qa/testdata.zip?${BUILD_TAG}" -O /tmp/photoprism/testdata.zip -# Install additional tools -COPY --chown=root:root --chmod=755 /docker/scripts/heif-convert.sh /usr/local/bin/heif-convert +# Copy additional files to image +COPY --chown=root:root /docker/scripts/heif-convert.sh /usr/local/bin/heif-convert +COPY --chown=root:root /docker/scripts/Makefile /root/Makefile +COPY --chown=root:root /docker/development/entrypoint.sh /entrypoint.sh + RUN env GO111MODULE=off /usr/local/go/bin/go get -u github.com/tianon/gosu \ golang.org/x/tools/cmd/goimports github.com/kyoh86/richgo && \ [ "$TARGETARCH" = "arm" ] || \ @@ -133,6 +136,7 @@ RUN useradd photoprism -m -U -u 1000 -d /photoprism && chmod a+rwx /photoprism & echo "photoprism ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ chown -Rf photoprism:photoprism /photoprism /var/lib/photoprism /tmp/photoprism && \ chmod -Rf a+rw /photoprism /var/lib/photoprism /tmp/photoprism /go && \ + chmod 755 /usr/local/bin/heif-convert /entrypoint.sh && \ find /go -type d -print0 | xargs -0 chmod 777 # Copy mysql client config for development @@ -148,7 +152,6 @@ EXPOSE 2342 2343 9515 VOLUME /var/lib/photoprism # Configure entrypoint -COPY --chown=root:root --chmod=755 /docker/development/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] # Run server diff --git a/docker/development/entrypoint.sh b/docker/development/entrypoint.sh index 58e2251a4..2f498a8e4 100755 --- a/docker/development/entrypoint.sh +++ b/docker/development/entrypoint.sh @@ -1,7 +1,17 @@ #!/usr/bin/env bash -if [[ $(id -u) = "0" ]]; then +if [[ $(id -u) == "0" ]]; then echo "development base image started as root" + + if [ -e /root/.init ]; then + echo "initialized" + elif [[ ${PHOTOPRISM_INIT} ]]; then + for target in $PHOTOPRISM_INIT; do + echo "init ${target}..." + make -f /root/Makefile "${target}" + done + echo 1 >/root/.init + fi else echo "development base image started as uid $(id -u)" fi @@ -21,7 +31,7 @@ if [[ ${PHOTOPRISM_UMASK} =~ $re ]]; then fi # Script runs as root? -if [[ $(id -u) = "0" ]]; then +if [[ $(id -u) == "0" ]]; then # Legacy user ID env variable in use? if [[ -z ${PHOTOPRISM_UID} ]] && [[ ${UID} =~ $re ]] && [[ ${UID} != "0" ]]; then PHOTOPRISM_UID=${UID} @@ -40,7 +50,7 @@ if [[ $(id -u) = "0" ]]; then useradd -o -u "${PHOTOPRISM_UID}" -g "${PHOTOPRISM_GID}" -d /photoprism "user_${PHOTOPRISM_UID}" 2>/dev/null usermod -g "${PHOTOPRISM_GID}" "user_${PHOTOPRISM_UID}" 2>/dev/null - if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then + if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]]; then echo "set PHOTOPRISM_DISABLE_CHOWN: \"true\" to disable storage permission updates" echo "updating storage permissions..." chown -Rf "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" /photoprism /var/lib/photoprism /tmp/photoprism /go @@ -55,7 +65,7 @@ if [[ $(id -u) = "0" ]]; then useradd -o -u "${PHOTOPRISM_UID}" -g 1000 -d /photoprism "user_${PHOTOPRISM_UID}" 2>/dev/null usermod -g 1000 "user_${PHOTOPRISM_UID}" 2>/dev/null - if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then + if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]]; then echo "set PHOTOPRISM_DISABLE_CHOWN: \"true\" to disable storage permission updates" echo "updating storage permissions..." chown -Rf "${PHOTOPRISM_UID}" /photoprism /var/lib/photoprism /tmp/photoprism /go @@ -83,4 +93,4 @@ fi PID=$! trap "kill $PID" INT TERM -wait \ No newline at end of file +wait diff --git a/docker/examples/arm64/docker-compose.yml b/docker/examples/arm64/docker-compose.yml index dbd288aa6..da97cbe06 100644 --- a/docker/examples/arm64/docker-compose.yml +++ b/docker/examples/arm64/docker-compose.yml @@ -57,6 +57,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection) PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality) PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow @@ -83,9 +84,9 @@ services: # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 HOME: "/photoprism" - # For hardware AVC transcoding using the h264_v4l2m2m encoder: + # Optional hardware devices for video transcoding and machine learning: # devices: - # - "/dev/video11:/dev/video11" + # - "/dev/video11:/dev/video11" # Video4Linux (h264_v4l2m2m) working_dir: "/photoprism" volumes: # Your photo and video files ([local path]:[container path]): diff --git a/docker/examples/cloud/digitalocean.json b/docker/examples/cloud/digitalocean.json index 0483e69d4..36b8efe3e 100644 --- a/docker/examples/cloud/digitalocean.json +++ b/docker/examples/cloud/digitalocean.json @@ -44,11 +44,11 @@ "echo 'APT::Install-Suggests \"false\";' > /etc/apt/apt.conf.d/80suggests", "echo 'APT::Get::Assume-Yes \"true\";' > /etc/apt/apt.conf.d/80forceyes", "echo 'APT::Get::Fix-Missing \"true\";' > /etc/apt/apt.conf.d/80fixmissing", - "apt-get -qqy update", + "apt-get -qq update", "apt dist-upgrade 2>/dev/null", - "apt-get -qqy install {{user `apt_packages`}}", - "apt-get -qqy autoclean", - "apt-get -qqy autoremove", + "apt-get -qq install {{user `apt_packages`}}", + "apt-get -qq autoclean", + "apt-get -qq autoremove", "chmod 700 /var/lib/cloud/scripts/per-instance/install_photoprism.sh" ] }, diff --git a/docker/examples/cloud/docker-compose.yml b/docker/examples/cloud/docker-compose.yml index 3abe65290..cdf1ce356 100644 --- a/docker/examples/cloud/docker-compose.yml +++ b/docker/examples/cloud/docker-compose.yml @@ -136,6 +136,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection) PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality) PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow @@ -149,6 +150,7 @@ services: PHOTOPRISM_DATABASE_NAME: "photoprism" # MariaDB database schema name PHOTOPRISM_DATABASE_USER: "photoprism" # MariaDB database user name PHOTOPRISM_DATABASE_PASSWORD: "_admin_password_" # MariaDB database user password + PHOTOPRISM_INIT: "tensorflow-amd64-avx2" HOME: "/photoprism" working_dir: "/photoprism" volumes: diff --git a/docker/examples/docker-compose.yml b/docker/examples/docker-compose.yml index c43fe44fb..ad427fb17 100644 --- a/docker/examples/docker-compose.yml +++ b/docker/examples/docker-compose.yml @@ -56,6 +56,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection) PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality) PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow @@ -79,7 +80,18 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + # Enable TensorFlow AVX2 support for modern Intel CPUs: + # PHOTOPRISM_INIT: "tensorflow-amd64-avx2" + # Hardware video transcoding options: + # PHOTOPRISM_FFMPEG_BUFFERS: "64" # FFmpeg capture buffers (default: 32) + # PHOTOPRISM_FFMPEG_ENCODER: "h264_v4l2m2m" # Use Video4Linux for AVC transcoding (default: libx264) + # PHOTOPRISM_FFMPEG_ENCODER: "h264_qsv" # Use Intel Quick Sync Video for AVC transcoding (default: libx264) + # PHOTOPRISM_INIT: "intel-graphics tensorflow-amd64-avx2" # Enable TensorFlow AVX2 & Intel Graphics support HOME: "/photoprism" + # Optional hardware devices for video transcoding and machine learning: + # devices: + # - "/dev/video11:/dev/video11" # Video4Linux (h264_v4l2m2m) + # - "/dev/dri/renderD128:/dev/dri/renderD128" # Intel GPU working_dir: "/photoprism" volumes: # Your photo and video files ([local path]:[container path]): diff --git a/docker/examples/macos/docker-compose.yml b/docker/examples/macos/docker-compose.yml index e93e750e6..f8f22f19d 100644 --- a/docker/examples/macos/docker-compose.yml +++ b/docker/examples/macos/docker-compose.yml @@ -52,6 +52,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection) PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality) PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow @@ -70,6 +71,7 @@ services: PHOTOPRISM_SITE_CAPTION: "Browse Your Life" PHOTOPRISM_SITE_DESCRIPTION: "" PHOTOPRISM_SITE_AUTHOR: "" + # PHOTOPRISM_INIT: "tensorflow-amd64-avx2" HOME: "/photoprism" volumes: # Your photo and video files ([local path]:[container path]): diff --git a/docker/examples/scheduler/docker-compose.yml b/docker/examples/scheduler/docker-compose.yml index 508c1a28f..9af227430 100644 --- a/docker/examples/scheduler/docker-compose.yml +++ b/docker/examples/scheduler/docker-compose.yml @@ -59,6 +59,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection) PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality) PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow @@ -82,6 +83,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + # PHOTOPRISM_INIT: "tensorflow-amd64-avx2" HOME: "/photoprism" working_dir: "/photoprism" volumes: diff --git a/docker/examples/sqlite/docker-compose.yml b/docker/examples/sqlite/docker-compose.yml index 26110bd46..aba4e4302 100644 --- a/docker/examples/sqlite/docker-compose.yml +++ b/docker/examples/sqlite/docker-compose.yml @@ -54,6 +54,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required (disables password protection) PHOTOPRISM_READONLY: "false" # Don't modify originals directory (reduced functionality) PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow @@ -72,6 +73,7 @@ services: # PHOTOPRISM_UID: 1000 # PHOTOPRISM_GID: 1000 # PHOTOPRISM_UMASK: 0000 + # PHOTOPRISM_INIT: "tensorflow-amd64-avx2" HOME: "/photoprism" working_dir: "/photoprism" volumes: diff --git a/docker/examples/windows/docker-compose.yml b/docker/examples/windows/docker-compose.yml index 57f330983..d1ed370cc 100644 --- a/docker/examples/windows/docker-compose.yml +++ b/docker/examples/windows/docker-compose.yml @@ -55,6 +55,7 @@ services: PHOTOPRISM_PUBLIC: "false" # No authentication required, disables password protection PHOTOPRISM_READONLY: "false" # Don't modify originals folder; disables import, upload, and delete PHOTOPRISM_EXPERIMENTAL: "false" # Enables experimental features + PHOTOPRISM_DISABLE_CHOWN: "false" # Disables storage permission updates on startup PHOTOPRISM_DISABLE_WEBDAV: "false" # Disables built-in WebDAV server PHOTOPRISM_DISABLE_SETTINGS: "false" # Disables Settings in Web UI PHOTOPRISM_DISABLE_TENSORFLOW: "false" # Disables all features depending on TensorFlow diff --git a/docker/photoprism/Dockerfile b/docker/photoprism/Dockerfile index 0c05e8c49..3e98f5dc8 100644 --- a/docker/photoprism/Dockerfile +++ b/docker/photoprism/Dockerfile @@ -31,10 +31,11 @@ RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry && \ echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissing # Install additional distribution packages -RUN apt-get update && apt dist-upgrade 2>/dev/null && apt-get -qq install -y --no-install-recommends \ +RUN apt-get update && apt-get -qq dist-upgrade && apt-get -qq install --no-install-recommends \ gpgv \ wget \ curl \ + make \ davfs2 \ ca-certificates \ mariadb-client \ @@ -83,6 +84,7 @@ ENV TF_CPP_MIN_LOG_LEVEL="2" \ PHOTOPRISM_DATABASE_NAME="photoprism" \ PHOTOPRISM_DATABASE_USER="photoprism" \ PHOTOPRISM_DATABASE_PASSWORD="" \ + PHOTOPRISM_DISABLE_CHOWN="false" \ PHOTOPRISM_DISABLE_WEBDAV="false" \ PHOTOPRISM_DISABLE_SETTINGS="false" \ PHOTOPRISM_DISABLE_BACKUPS="false" \ @@ -113,10 +115,12 @@ RUN ldconfig RUN umask 0000 && useradd photoprism -m -U -u 1000 -d /photoprism && chmod a+rwx /photoprism WORKDIR /photoprism -# Copy files to /photoprism +# Copy additional files to image COPY --from=build /root/.local/bin/photoprism /photoprism/bin/photoprism COPY --from=build /root/.photoprism/assets /photoprism/assets -COPY --chown=root:root --chmod=755 /docker/scripts/heif-convert.sh /usr/local/bin/heif-convert +COPY --chown=root:root /docker/scripts/heif-convert.sh /usr/local/bin/heif-convert +COPY --chown=root:root /docker/scripts/Makefile /root/Makefile +COPY --chown=root:root /docker/photoprism/entrypoint.sh /entrypoint.sh # Create directories RUN mkdir -m 777 -p \ @@ -127,7 +131,8 @@ RUN mkdir -m 777 -p \ /photoprism/storage/config \ /photoprism/storage/cache && \ chown -Rf photoprism:photoprism /photoprism /var/lib/photoprism /tmp/photoprism && \ - chmod -Rf a+rwx /photoprism /var/lib/photoprism /tmp/photoprism + chmod -Rf a+rwx /photoprism /var/lib/photoprism /tmp/photoprism && \ + chmod 755 /usr/local/bin/heif-convert /entrypoint.sh # Show photoprism version RUN photoprism -v @@ -136,7 +141,6 @@ RUN photoprism -v EXPOSE 2342 # Configure entrypoint -COPY --chown=root:root --chmod=755 /docker/scripts/entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] VOLUME /var/lib/photoprism diff --git a/docker/scripts/entrypoint.sh b/docker/photoprism/entrypoint.sh similarity index 87% rename from docker/scripts/entrypoint.sh rename to docker/photoprism/entrypoint.sh index bcd5e71ff..d6099e56a 100755 --- a/docker/scripts/entrypoint.sh +++ b/docker/photoprism/entrypoint.sh @@ -1,7 +1,17 @@ #!/usr/bin/env bash -if [[ $(id -u) = "0" ]]; then +if [[ $(id -u) == "0" ]]; then echo "started as root" + + if [ -e /root/.init ]; then + echo "initialized" + elif [[ ${PHOTOPRISM_INIT} ]]; then + for target in $PHOTOPRISM_INIT; do + echo "init ${target}..." + make -f /root/Makefile "${target}" + done + echo 1 >/root/.init + fi fi re='^[0-9]+$' @@ -19,7 +29,7 @@ if [[ ${PHOTOPRISM_UMASK} =~ $re ]]; then fi # Script runs as root? -if [[ $(id -u) = "0" ]]; then +if [[ $(id -u) == "0" ]]; then # Legacy user ID env variable in use? if [[ -z ${PHOTOPRISM_UID} ]] && [[ ${UID} =~ $re ]] && [[ ${UID} != "0" ]]; then PHOTOPRISM_UID=${UID} @@ -38,7 +48,7 @@ if [[ $(id -u) = "0" ]]; then useradd -o -u "${PHOTOPRISM_UID}" -g "${PHOTOPRISM_GID}" -d /photoprism "user_${PHOTOPRISM_UID}" 2>/dev/null usermod -g "${PHOTOPRISM_GID}" "user_${PHOTOPRISM_UID}" 2>/dev/null - if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then + if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]]; then echo "set PHOTOPRISM_DISABLE_CHOWN: \"true\" to disable storage permission updates" echo "updating storage permissions..." chown -Rf "${PHOTOPRISM_UID}:${PHOTOPRISM_GID}" /photoprism/storage /photoprism/import /photoprism/assets /var/lib/photoprism /tmp/photoprism @@ -53,7 +63,7 @@ if [[ $(id -u) = "0" ]]; then useradd -o -u "${PHOTOPRISM_UID}" -g 1000 -d /photoprism "user_${PHOTOPRISM_UID}" 2>/dev/null usermod -g 1000 "user_${PHOTOPRISM_UID}" 2>/dev/null - if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]] ; then + if [[ -z ${PHOTOPRISM_DISABLE_CHOWN} ]]; then echo "set PHOTOPRISM_DISABLE_CHOWN: \"true\" to disable storage permission updates" echo "updating storage permissions..." chown -Rf "${PHOTOPRISM_UID}" /photoprism/storage /photoprism/import /photoprism/assets /var/lib/photoprism /tmp/photoprism @@ -81,4 +91,4 @@ fi PID=$! trap "kill $PID" INT TERM -wait \ No newline at end of file +wait diff --git a/docker/scripts/Makefile b/docker/scripts/Makefile new file mode 100644 index 000000000..0f074650a --- /dev/null +++ b/docker/scripts/Makefile @@ -0,0 +1,28 @@ +# Optional packages and drivers for PhotoPrism +# Maintainer: Michael Mayer +.PHONY: tensorflow-amd64-avx tensorflow-amd64-avx-install \ + tensorflow-amd64-avx2 tensorflow-amd64-avx2-install \ + tensorflow-amd64-cpu tensorflow-amd64-cpu-install \ + intel-graphics; +tensorflow-amd64-avx: /tmp/libtensorflow-linux-avx-1.15.2.tar.gz tensorflow-amd64-avx-install +/tmp/libtensorflow-linux-avx-1.15.2.tar.gz: + curl -fsSL "https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-avx-1.15.2.tar.gz" > /tmp/libtensorflow-linux-avx-1.15.2.tar.gz +tensorflow-amd64-avx-install: + tar --overwrite -C "/usr" -xzf /tmp/libtensorflow-linux-avx-1.15.2.tar.gz + ldconfig +tensorflow-amd64-avx2: /tmp/libtensorflow-linux-avx2-1.15.2.tar.gz tensorflow-amd64-avx2-install +/tmp/libtensorflow-linux-avx2-1.15.2.tar.gz: + curl -fsSL "https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-avx2-1.15.2.tar.gz" > /tmp/libtensorflow-linux-avx2-1.15.2.tar.gz +tensorflow-amd64-avx2-install: + tar --overwrite -C "/usr" -xzf /tmp/libtensorflow-linux-avx2-1.15.2.tar.gz + ldconfig +tensorflow-amd64-cpu: /tmp/libtensorflow-linux-cpu-1.15.2.tar.gz tensorflow-amd64-cpu-install +/tmp/libtensorflow-linux-cpu-1.15.2.tar.gz: + curl -fsSL "https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-cpu-1.15.2.tar.gz" > /tmp/libtensorflow-linux-cpu-1.15.2.tar.gz +tensorflow-amd64-cpu-install: + tar --overwrite -C "/usr" -xzf /tmp/libtensorflow-linux-cpu-1.15.2.tar.gz + ldconfig +intel-graphics: + apt-get update + apt-get install intel-opencl-icd intel-media-va-driver-non-free libmfx1 + apt-get -y autoremove && apt-get -y autoclean && apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/docker/scripts/install-tensorflow.sh b/docker/scripts/install-tensorflow.sh index 473716282..d943d1ecf 100755 --- a/docker/scripts/install-tensorflow.sh +++ b/docker/scripts/install-tensorflow.sh @@ -18,8 +18,8 @@ else exit 1 fi echo "$URL" - curl -L "$URL" | \ - tar -C "/usr" -xz && \ + curl -fsSL "$URL" | \ + tar --overwrite -C "/usr" -xz && \ ldconfig echo "Done" fi