174 lines
7.8 KiB
Docker
174 lines
7.8 KiB
Docker
FROM --platform=$BUILDPLATFORM alpine:3.24 AS download
|
|
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
|
|
# renovate: datasource=github-releases depName=nextcloud packageName=nextcloud/server
|
|
ARG NEXTCLOUD_VERSION=v35.0.3
|
|
# download.nextcloud.com releases are named without the "v" prefix used by the github tag;
|
|
# the .sha512 file's entries reference the .zip/.metadata filenames verbatim, so those two
|
|
# still need to be fetched under their original names for sha512sum -c to find them.
|
|
RUN version="${NEXTCLOUD_VERSION#v}" && \
|
|
wget -q "https://download.nextcloud.com/server/releases/nextcloud-${version}.zip" -O "nextcloud-${version}.zip" && \
|
|
wget -q "https://download.nextcloud.com/server/releases/nextcloud-${version}.metadata" -O "nextcloud-${version}.metadata" && \
|
|
wget -q "https://download.nextcloud.com/server/releases/nextcloud-${version}.zip.sha512" -O nextcloud.zip.sha512 && \
|
|
apk add --no-cache unzip && \
|
|
sha512sum -c nextcloud.zip.sha512 && \
|
|
unzip -q "nextcloud-${version}.zip" && \
|
|
rm -f "nextcloud-${version}.zip" "nextcloud-${version}.metadata" nextcloud.zip.sha512
|
|
|
|
FROM dunglas/frankenphp:1.13.5-php8.5.12-alpine AS php-base
|
|
|
|
# PHP extensions are compiled from source. Run serially (one install-php-extensions call)
|
|
# that takes ~1h for the QEMU-emulated arm64 build, so every extension gets its own stage:
|
|
# BuildKit builds independent stages in parallel. The toolchain is installed once here.
|
|
FROM php-base AS ext-builder
|
|
RUN apk add --no-cache $PHPIZE_DEPS
|
|
|
|
FROM ext-builder AS ext-apcu
|
|
RUN install-php-extensions apcu
|
|
FROM ext-builder AS ext-bcmath
|
|
RUN install-php-extensions bcmath
|
|
FROM ext-builder AS ext-exif
|
|
RUN install-php-extensions exif
|
|
FROM ext-builder AS ext-ftp
|
|
RUN install-php-extensions ftp
|
|
FROM ext-builder AS ext-gd
|
|
RUN install-php-extensions gd
|
|
FROM ext-builder AS ext-gmp
|
|
RUN install-php-extensions gmp
|
|
FROM ext-builder AS ext-imagick
|
|
RUN install-php-extensions imagick
|
|
FROM ext-builder AS ext-imap
|
|
RUN install-php-extensions imap
|
|
FROM ext-builder AS ext-intl
|
|
RUN install-php-extensions intl
|
|
FROM ext-builder AS ext-ldap
|
|
RUN install-php-extensions ldap
|
|
FROM ext-builder AS ext-pcntl
|
|
RUN install-php-extensions pcntl
|
|
FROM ext-builder AS ext-pgsql
|
|
RUN install-php-extensions pdo_pgsql pgsql
|
|
FROM ext-builder AS ext-redis
|
|
RUN install-php-extensions redis
|
|
FROM ext-builder AS ext-sysvsem
|
|
RUN install-php-extensions sysvsem
|
|
FROM ext-builder AS ext-zip
|
|
RUN install-php-extensions zip
|
|
|
|
FROM php-base AS extensions
|
|
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
|
|
ARG EXT_DIR=/usr/local/lib/php/extensions
|
|
ARG INI_DIR=/usr/local/etc/php/conf.d
|
|
COPY --from=ext-apcu $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-apcu $INI_DIR $INI_DIR
|
|
COPY --from=ext-bcmath $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-bcmath $INI_DIR $INI_DIR
|
|
COPY --from=ext-exif $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-exif $INI_DIR $INI_DIR
|
|
COPY --from=ext-ftp $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-ftp $INI_DIR $INI_DIR
|
|
COPY --from=ext-gd $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-gd $INI_DIR $INI_DIR
|
|
COPY --from=ext-gmp $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-gmp $INI_DIR $INI_DIR
|
|
COPY --from=ext-imagick $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-imagick $INI_DIR $INI_DIR
|
|
COPY --from=ext-imap $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-imap $INI_DIR $INI_DIR
|
|
COPY --from=ext-intl $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-intl $INI_DIR $INI_DIR
|
|
COPY --from=ext-ldap $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-ldap $INI_DIR $INI_DIR
|
|
COPY --from=ext-pcntl $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-pcntl $INI_DIR $INI_DIR
|
|
COPY --from=ext-pgsql $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-pgsql $INI_DIR $INI_DIR
|
|
COPY --from=ext-redis $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-redis $INI_DIR $INI_DIR
|
|
COPY --from=ext-sysvsem $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-sysvsem $INI_DIR $INI_DIR
|
|
COPY --from=ext-zip $EXT_DIR $EXT_DIR
|
|
COPY --from=ext-zip $INI_DIR $INI_DIR
|
|
# The extension stages' runtime libraries don't come along with the .so files; record the
|
|
# shared objects they link against (same approach as the official php image) so the
|
|
# production stage can apk add exactly those.
|
|
RUN scanelf --needed --nobanner --format '%n#p' --recursive "$EXT_DIR" | \
|
|
tr ',' '\n' | sort -u | \
|
|
awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' > /php-runtime-deps
|
|
|
|
FROM php-base AS production
|
|
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
|
|
ARG SYSTEM_USERNAME=nextcloud
|
|
ENV PHP_MEMORY_LIMIT=2048M \
|
|
PHP_MAX_UPLOAD=128G \
|
|
PHP_MAX_FILE_UPLOAD=200 \
|
|
PHP_MAX_POST=128G \
|
|
PHP_DISPLAY_ERRORS=Off \
|
|
PHP_DISPLAY_STARTUP_ERRORS=Off \
|
|
PHP_ERROR_REPORTING="E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR" \
|
|
PHP_LOG_LEVEL=notice \
|
|
PHP_EXPOSE_INFO=Off \
|
|
PHP_APC_CACHE_SIZE=126M \
|
|
NEXTCLOUD_DB_NAME=nextcloud \
|
|
NEXTCLOUD_DB_HOST=postgres \
|
|
NEXTCLOUD_DB_USER=nextcloud \
|
|
NEXTCLOUD_DB_PASS="" \
|
|
NEXTCLOUD_ADMIN_USER="admin" \
|
|
NEXTCLOUD_ADMIN_PASS="" \
|
|
NEXTCLOUD_DOMAIN="mynextcloud.de" \
|
|
NEXTCLOUD_ADDITIONAL_CONFIG="{}" \
|
|
REDIS_HOST="redis" \
|
|
REDIS_PHP_DBINDEX="0" \
|
|
REDIS_NEXTCLOUD_DBINDEX="1" \
|
|
NOTIFY_PUSH_DAEMON_ENABLED=1 \
|
|
SIDECAR_NOTIFY_PUSH=0 \
|
|
SIDECAR_FULLTEXTSEARCH=0 \
|
|
NEXTCLOUD_SERVICE_NAME=nextcloud \
|
|
NEXTCLOUD_OVERWRITE_PROTOCOL=https \
|
|
NEXTCLOUD_DBPERSISTENCE=true \
|
|
NOTIFY_PUSH_BINPATH=/data/apps/notify_push/bin/x86_64/notify_push \
|
|
EXIT_AFTER_INSTALL=0 \
|
|
RUN_CRON=1
|
|
|
|
COPY --from=extensions /usr/local/lib/php/extensions /usr/local/lib/php/extensions
|
|
COPY --from=extensions /usr/local/etc/php/conf.d /usr/local/etc/php/conf.d
|
|
# Packages install-php-extensions would keep but the extensions don't link against: the
|
|
# imagemagick format coders (imagick only links imagemagick-libs) and the full ICU locale
|
|
# data for intl (icu-libs alone only pulls in the English data).
|
|
RUN --mount=type=bind,from=extensions,source=/php-runtime-deps,target=/tmp/php-runtime-deps \
|
|
apk add --no-cache ffmpeg supercronic netcat-openbsd icu-data-full \
|
|
imagemagick imagemagick-heic imagemagick-jp2 imagemagick-pdf imagemagick-raw imagemagick-svg imagemagick-tiff \
|
|
$(cat /tmp/php-runtime-deps) && \
|
|
addgroup -S -g 1001 $SYSTEM_USERNAME && \
|
|
adduser -S -H -D -s /sbin/nologin -G $SYSTEM_USERNAME -u 1001 $SYSTEM_USERNAME && \
|
|
chown -R $SYSTEM_USERNAME:$SYSTEM_USERNAME /usr/local/etc/php/conf.d && \
|
|
chmod -R g+w /usr/local/etc/php/conf.d && \
|
|
mkdir -p /etc/crontabs && \
|
|
echo "* * * * * php /var/www/html/cron.php" > /etc/crontabs/nextcloud && \
|
|
echo "0 0 * * * occ db:add-missing-indices" >> /etc/crontabs/nextcloud && \
|
|
chown $SYSTEM_USERNAME:$SYSTEM_USERNAME /etc/crontabs/nextcloud && \
|
|
{ find / -xdev -type f -perm /6000 -exec chmod a-s {} + 2>/dev/null || true; } && \
|
|
rm -rf /var/cache/apk/*
|
|
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0640 opcache.ini /usr/local/etc/php/conf.d/opcache-nextcloud.ini
|
|
COPY --chown=root:root --chmod=0644 Caddyfile /etc/caddy/Caddyfile
|
|
# Ownership/mode set at COPY time (not via a later RUN chown/chmod -R): on overlayfs any
|
|
# metadata-only change to a file forces a full copy-up into a new layer, so fixing up a
|
|
# tree this size after the fact would silently double the image size.
|
|
COPY --from=download --chown=root:$SYSTEM_USERNAME --chmod=0750 nextcloud/ /var/www/html/
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0640 ./config-patch.php /config-patch.php
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0640 common.sh /usr/local/bin/common.sh
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0750 start.sh /usr/local/bin/start.sh
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0750 setup.sh /usr/local/bin/setup.sh
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0750 serve.sh /usr/local/bin/serve.sh
|
|
COPY --chown=root:$SYSTEM_USERNAME --chmod=0750 cron.sh /usr/local/bin/cron.sh
|
|
|
|
RUN rm -rf /var/www/html/config && \
|
|
ln -s /var/www/html/occ /usr/local/bin/occ && \
|
|
ln -s /data/config /var/www/html/config && \
|
|
ln -s /data/apps /var/www/html/custom_apps
|
|
|
|
WORKDIR /var/www/html/
|
|
EXPOSE 8080
|
|
STOPSIGNAL SIGTERM
|
|
USER $SYSTEM_USERNAME
|
|
ENTRYPOINT []
|
|
CMD ["ash", "/usr/local/bin/start.sh"]
|