diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index 8695d513..bb05eb27 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -1,15 +1,21 @@ -# From https://github.com/nextcloud/docker/blob/master/22/fpm/Dockerfile -FROM php:8.0-fpm-bullseye +# From https://github.com/nextcloud/docker/blob/master/23/fpm-alpine/Dockerfile +FROM php:8.0-fpm-alpine + +# Custom: change id of www-data user as it needs to be the same like on old installations +RUN set -ex; \ + apk add --no-cache shadow; \ + deluser www-data; \ + groupmod -g 333 xfs; \ + usermod -u 333 -g 333 xfs; \ + addgroup -g 33 -S www-data; \ + adduser -u 33 -D -S -G www-data www-data # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ - apt-get update; \ - apt-get install -y --no-install-recommends \ + apk add --no-cache \ rsync \ - bzip2 \ - ; \ - rm -rf /var/lib/apt/lists/*; + ; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html @@ -17,30 +23,28 @@ ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 10G RUN set -ex; \ \ - savedAptMark="$(apt-mark showmanual)"; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - libcurl4-openssl-dev \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + autoconf \ + freetype-dev \ + icu-dev \ libevent-dev \ - libfreetype6-dev \ - libicu-dev \ - libjpeg-dev \ - libldap2-dev \ + libjpeg-turbo-dev \ libmcrypt-dev \ - libmemcached-dev \ libpng-dev \ - libpq-dev \ + libmemcached-dev \ libxml2-dev \ - libmagickwand-dev \ libzip-dev \ + openldap-dev \ + pcre-dev \ + postgresql-dev \ + imagemagick-dev \ libwebp-dev \ - libgmp-dev \ + gmp-dev \ ; \ \ - debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ - docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-configure ldap; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ @@ -69,19 +73,14 @@ RUN set -ex; \ ; \ rm -r /tmp/pear; \ \ -# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies - apt-mark auto '.*' > /dev/null; \ - apt-mark manual $savedAptMark; \ - ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ - | awk '/=>/ { print $3 }' \ - | sort -u \ - | xargs -r dpkg-query -S \ - | cut -d: -f1 \ - | sort -u \ - | xargs -rt apt-mark manual; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/* + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/server_tuning.html#enable-php-opcache @@ -109,12 +108,10 @@ VOLUME /var/www/html ENV NEXTCLOUD_VERSION 23.0.1 RUN set -ex; \ - fetchDeps=" \ + apk add --no-cache --virtual .fetch-deps \ + bzip2 \ 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-${NEXTCLOUD_VERSION}.tar.bz2"; \ @@ -122,7 +119,7 @@ RUN set -ex; \ "https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_VERSION}.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 --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; \ @@ -131,9 +128,7 @@ RUN set -ex; \ mkdir -p /usr/src/nextcloud/data; \ mkdir -p /usr/src/nextcloud/custom_apps; \ chmod +x /usr/src/nextcloud/occ; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ - rm -rf /var/lib/apt/lists/* + apk del .fetch-deps COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ @@ -141,31 +136,28 @@ COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] -# Template from https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/full/fpm/Dockerfile +# Template from https://github.com/nextcloud/docker/blob/master/.examples/dockerfiles/full/fpm-alpine/Dockerfile RUN set -ex; \ \ - apt-get update; \ - apt-get install -y --no-install-recommends \ + apk add --no-cache \ ffmpeg \ - libmagickcore-6.q16-6-extra \ + imagemagick \ procps \ - smbclient \ + samba-client \ supervisor \ # libreoffice \ - ; \ - rm -rf /var/lib/apt/lists/* + ; RUN set -ex; \ \ - savedAptMark="$(apt-mark showmanual)"; \ - \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - libbz2-dev \ - libc-client-dev \ - libkrb5-dev \ - libsmbclient-dev \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + imap-dev \ + krb5-dev \ + openssl-dev \ + samba-dev \ + bzip2-dev \ ; \ \ docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ @@ -176,19 +168,14 @@ RUN set -ex; \ pecl install smbclient; \ docker-php-ext-enable smbclient; \ \ -# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies - apt-mark auto '.*' > /dev/null; \ - apt-mark manual $savedAptMark; \ - ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ - | awk '/=>/ { print $3 }' \ - | sort -u \ - | xargs -r dpkg-query -S \ - | cut -d: -f1 \ - | sort -u \ - | xargs -rt apt-mark manual; \ - \ - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ - rm -rf /var/lib/apt/lists/* + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps RUN mkdir -p \ /var/log/supervisord \ @@ -204,12 +191,11 @@ CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] # Custom: RUN set -ex; \ \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - netcat \ + apk add --no-cache \ + bash \ + netcat-openbsd \ openssl \ gnupg \ - dirmngr \ git \ postgresql-client \ ; \ @@ -222,14 +208,16 @@ RUN set -ex; \ sed -i 's/^pm.min_spare_servers =.*/pm.min_spare_servers = 25/' /usr/local/etc/php-fpm.d/www.conf; \ sed -i 's/^pm.max_spare_servers =.*/pm.max_spare_servers = 75/' /usr/local/etc/php-fpm.d/www.conf -RUN rm -rf /tmp/nextcloud-aio && \ +RUN set -ex; \ + rm -rf /tmp/nextcloud-aio && \ mkdir -p /tmp/nextcloud-aio && \ cd /tmp/nextcloud-aio && \ git clone https://github.com/nextcloud-releases/all-in-one.git --depth 1 .; \ mkdir -p /usr/src/nextcloud/apps/nextcloud-aio; \ cp -r ./app/* /usr/src/nextcloud/apps/nextcloud-aio/ -RUN chown www-data:root -R /usr/src && \ +RUN set -ex; \ + chown www-data:root -R /usr/src && \ chown www-data:root -R /usr/local/etc/php/conf.d && \ chown www-data:root -R /var/log/supervisord/ && \ chown www-data:root -R /var/run/supervisord/ && \ @@ -239,14 +227,16 @@ RUN chown www-data:root -R /usr/src && \ COPY start.sh / COPY notify.sh / -RUN chmod +x /start.sh && \ +RUN set -ex; \ + chmod +x /start.sh && \ chmod +r /supervisord.conf && \ chmod +x /entrypoint.sh && \ chmod +r /upgrade.exclude && \ chmod +x /cron.sh && \ chmod +x /notify.sh -RUN mkdir /mnt/ncdata; \ +RUN set -ex; \ + mkdir /mnt/ncdata; \ chown www-data:www-data /mnt/ncdata; VOLUME /mnt/ncdata