From 4d4e2741f2ee5af02e816aa4de3a44a4c25aa2c7 Mon Sep 17 00:00:00 2001 From: jimmyGALLAND Date: Sat, 28 Feb 2026 17:19:02 +0100 Subject: [PATCH] update dockerbuild --- 33/Dockerfile | 204 ++++++++++++++++++++++++-------------------------- 1 file changed, 96 insertions(+), 108 deletions(-) diff --git a/33/Dockerfile b/33/Dockerfile index 0edb28b..db66955 100644 --- a/33/Dockerfile +++ b/33/Dockerfile @@ -1,39 +1,17 @@ ARG NC_VERS -FROM php:8.4-apache-trixie +############################ +# STAGE 1 ? BUILD +############################ +FROM php:8.4-apache-trixie AS build + ARG NC_VERS -ENV NEXTCLOUD_VERSION ${NC_VERS} +ENV NEXTCLOUD_VERSION=${NC_VERS} - -# entrypoint.sh and cron.sh dependencies -RUN set -ex; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - rsync \ - bzip2 \ - busybox-static \ - libldap-common \ - libmagickcore-7.q16-10-extra \ - libzip5 \ - libmemcached11 \ - ; \ - - rm -rf /var/lib/apt/lists/*; \ - \ - mkdir -p /var/spool/cron/crontabs; \ - echo '*/5 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data - -# install the PHP extensions we need -# see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html -ENV PHP_MEMORY_LIMIT 512M -ENV PHP_UPLOAD_LIMIT 512M -RUN set -ex; \ - \ - savedAptMark="$(apt-mark showmanual)"; \ - \ +RUN set -eux; \ apt-get update; \ apt-get install -y --no-install-recommends \ + build-essential \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ @@ -49,18 +27,23 @@ RUN set -ex; \ libzip-dev \ libwebp-dev \ libgmp-dev \ - imagemagick \ - libbz2-dev \ + libbz2-dev \ + git \ + curl \ + gnupg \ + dirmngr \ ; \ - \ + rm -rf /var/lib/apt/lists/* + +RUN set -eux; \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-ftp-ssl; \ - docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ + docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ - docker-php-ext-install -j "$(nproc)" \ + docker-php-ext-install -j"$(nproc)" \ bcmath \ exif \ - ftp \ + ftp \ gd \ intl \ ldap \ @@ -69,41 +52,92 @@ RUN set -ex; \ pdo_mysql \ pdo_pgsql \ sysvsem \ - zip \ + zip \ gmp \ - bz2 \ - ; \ - \ -# pecl will claim success even if one install fails, so we need to perform each install separately + bz2 + +RUN set -eux; \ pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ - pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ pecl install memcached-3.4.0; \ pecl install redis-6.3.0; \ - pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ pecl install imagick-3.8.1; \ - \ docker-php-ext-enable \ apcu \ - memcached \ igbinary \ - imagick \ + memcached \ redis \ - bz2 \ + imagick + +############################ +# STAGE 2 ? RUNTIME +############################ +FROM php:8.4-apache-trixie + +ARG NC_VERS +ENV NEXTCLOUD_VERSION=${NC_VERS} + +# Runtime libraries ONLY (pas de -dev) +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ffmpeg \ + ghostscript \ + procps \ + fontconfig \ + exiftool \ + libldap-common \ + libmagickcore-7.q16-10-extra \ + libzip5 \ + libmemcached11 \ + libicu76 \ + libpq5 \ + libfreetype6 \ + libjpeg62-turbo \ + libpng16-16 \ + libwebp7 \ + libgmp10 \ + libbz2-1.0 \ + imagemagick \ ; \ - rm -r /tmp/pear; \ - apt-mark auto '.*' > /dev/null; \ - apt-mark manual $savedAptMark; \ - ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ - | awk '/=>/ { print $3 }' \ - | sort -u \ - | xargs -rt dpkg-query --search \ -# https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) - | awk 'sub(":$", "", $1) { print $1 }' \ - | sort -u \ - | xargs -rt apt-mark manual; + rm -rf /var/lib/apt/lists/* + +RUN set -ex; \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/5 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data +# Copier extensions compilées +COPY --from=build /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/ +COPY --from=build /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/ + +# Apache modules +RUN a2enmod headers rewrite remoteip + +# PHP tuning +ENV PHP_MEMORY_LIMIT=2048M +ENV PHP_UPLOAD_LIMIT=2048M + +############################ +# INSTALL NEXTCLOUD +############################ +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends curl gnupg dirmngr; \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/releases/nextcloud-${NC_VERS}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/releases/nextcloud-${NC_VERS}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /var/www/; \ + rm -rf "$GNUPGHOME" nextcloud.tar.bz2 nextcloud.tar.bz2.asc; \ + rm -rf /var/www/nextcloud/updater; \ + chown -R www-data:www-data /var/www/nextcloud # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache @@ -126,14 +160,10 @@ RUN { \ echo 'post_max_size=${PHP_UPLOAD_LIMIT}'; \ } > "${PHP_INI_DIR}/conf.d/nextcloud.ini"; \ \ - mkdir /var/www/data; \ - chown -R www-data:root /var/www; \ - chmod -R g=u /var/www + mkdir /var/www/data; -VOLUME /var/www/html -RUN a2enmod headers rewrite remoteip ;\ - {\ +RUN {\ echo RemoteIPHeader X-Real-IP ;\ echo RemoteIPTrustedProxy 10.0.0.0/8 ;\ echo RemoteIPTrustedProxy 172.16.0.0/12 ;\ @@ -148,53 +178,13 @@ RUN { \ } > /etc/apache2/conf-available/apache-limits.conf; \ a2enconf apache-limits -RUN set -ex; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - ffmpeg \ - ghostscript \ - procps \ - vim \ - fontconfig \ - exiftool \ - gnupg; \ - docker-php-ext-enable imagick - -RUN set -ex; \ - fetchDeps=" \ - gnupg \ - dirmngr \ - "; \ - apt-get update; \ - apt-get install -y --no-install-recommends $fetchDeps; \ - \ - curl -fsSL -o nextcloud.tar.bz2 \ - "https://download.nextcloud.com/server/releases/nextcloud-${NC_VERS}.tar.bz2"; \ - curl -fsSL -o nextcloud.tar.bz2.asc \ - "https://download.nextcloud.com/server/releases/nextcloud-${NC_VERS}.tar.bz2.asc"; \ - export GNUPGHOME="$(mktemp -d)"; \ -# gpg key from https://nextcloud.com/nextcloud.asc \ - gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ - gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ - tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ - gpgconf --kill all; \ - rm nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ - rm -rf "$GNUPGHOME" /usr/src/nextcloud/updater; \ - mkdir -p /usr/src/nextcloud/data; \ - mkdir -p /usr/src/nextcloud/custom_apps; \ - chmod +x /usr/src/nextcloud/occ; - COPY *.sh upgrade.exclude / RUN chmod +x /entrypoint.sh RUN chmod +x /cron.sh COPY config/* /usr/src/nextcloud/config/ - ENV NEXTCLOUD_UPDATE=1 -ENV PHP_MEMORY_LIMIT=2048M -ENV PHP_UPLOAD_LIMIT=2048M ENV extra_params=--o:net.proto=IPv4 -ENV NEXTCLOUD_VERSION ${NC_VERS} RUN sh -x && \ for file in `convert -list policy | grep "Path:" | grep -v built | sed 's/Path: \(.*\)/\1/g'`; \ @@ -202,10 +192,8 @@ RUN sh -x && \ sed -i 's/domain="coder" rights="none" pattern="PDF"/domain="coder" rights="read|write" pattern="PDF"/g' $file ;\ done -RUN set -ex; \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/* +VOLUME /var/www/html ENTRYPOINT ["/entrypoint.sh"] -CMD ["apache2-foreground"] +CMD ["apache2-foreground"] \ No newline at end of file