From 7bca6b3d2e83b2fb70c95b638570f24884fce00a Mon Sep 17 00:00:00 2001 From: Simon L Date: Thu, 10 Nov 2022 19:16:33 +0100 Subject: [PATCH] follow-up to #1377 Signed-off-by: Simon L --- Containers/nextcloud/Dockerfile | 2 -- Containers/nextcloud/start.sh | 29 +++++++++++++++++++------ docker-compose.yml | 2 +- manual-install/update-yaml.sh | 2 +- php/src/Data/ConfigurationManager.php | 2 +- readme.md | 2 +- tests/QA/060-environmental-variables.md | 2 +- 7 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Containers/nextcloud/Dockerfile b/Containers/nextcloud/Dockerfile index a4f9e4c1..ccc7d8ca 100644 --- a/Containers/nextcloud/Dockerfile +++ b/Containers/nextcloud/Dockerfile @@ -39,7 +39,6 @@ RUN set -ex; \ openldap-dev \ pcre-dev \ postgresql-dev \ - imagemagick-dev \ libwebp-dev \ gmp-dev \ ; \ @@ -142,7 +141,6 @@ RUN set -ex; \ \ apk add --no-cache \ ffmpeg \ - imagemagick \ procps \ samba-client \ supervisor \ diff --git a/Containers/nextcloud/start.sh b/Containers/nextcloud/start.sh index ab44b741..a53d13b8 100644 --- a/Containers/nextcloud/start.sh +++ b/Containers/nextcloud/start.sh @@ -55,6 +55,14 @@ if [ -n "$ADDITIONAL_PHP_EXTENSIONS" ]; then if ! [ -f "/additional-php-extensions-are-installed" ]; then read -ra ADDITIONAL_PHP_EXTENSIONS_ARRAY <<< "$ADDITIONAL_PHP_EXTENSIONS" for app in "${ADDITIONAL_PHP_EXTENSIONS_ARRAY[@]}"; do + # shellcheck disable=SC2086 + if [ "$PHP_DEPS_ARE_INSTALLED" != 1 ]; then + echo "Installing PHP build dependencies..." + if ! apk add --no-cache --virtual .build-deps libxml2-dev imagemagick-dev autoconf $PHPIZE_DEPS >/dev/null; then + echo "Could not install build-deps!" + fi + PHP_DEPS_ARE_INSTALLED=1 + fi if [ "$app" = imagick ]; then echo "Installing Imagick via PECL..." pecl install imagick-3.7.0 >/dev/null @@ -74,19 +82,26 @@ if [ -n "$ADDITIONAL_PHP_EXTENSIONS" ]; then fi else echo "Installing PHP extension $app ..." - if pecl install "$app" >/dev/null; then + if ! docker-php-ext-install -j "$(nproc)" "$app" >/dev/null; then + echo "Could not install $app from core. Trying to install from PECL..." + pecl install "$app" >/dev/null if ! docker-php-ext-enable "$app" >/dev/null; then - echo "Could not install PHP extension $app!" - fi - else - echo "Could not install $app using PECL. Trying to install from core..." - if ! docker-php-ext-install -j "$(nproc)" "$app" >/dev/null; then - echo "Could also not install $app from core. The PHP extensions was not installed!" + echo "Could also not install $app from PECL. The PHP extensions was not installed!" fi fi fi done fi + rm -rf /tmp/pear + 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 }' \ + )"; + # shellcheck disable=SC2086 + apk add --virtual .nextcloud-phpext-rundeps $runDeps >/dev/null + apk del .build-deps >/dev/null touch /additional-php-extensions-are-installed fi diff --git a/docker-compose.yml b/docker-compose.yml index b654038f..1a029f7e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -30,7 +30,7 @@ services: # - NEXTCLOUD_TRUSTED_CACERTS_DIR=/path/to/my/cacerts # CA certificates in this directory will be trusted by the OS of the nexcloud container (Useful e.g. for LDAPS) See See https://github.com/nextcloud/all-in-one#how-to-trust-user-defiend-certification-authorities-ca # - COLLABORA_SECCOMP_DISABLED=false # Setting this to true allows to disable Collabora's Seccomp feature. See https://github.com/nextcloud/all-in-one#how-to-disable-collaboras-seccomp-feature # - NEXTCLOUD_STARTUP_APPS=twofactor_totp deck tasks calendar contacts apporder # Allows to modify the Nextcloud apps that are installed on starting AIO the first time. See https://github.com/nextcloud/all-in-one#how-to-change-the-nextcloud-apps-that-are-installed-on-the-first-startup - # - NEXTCLOUD_ADDITIONAL_APKS=imagick # This allows to add additional packages to the Nextcloud container permanently. See https://github.com/nextcloud/all-in-one#how-to-add-packets-permanently-to-the-nextcloud-container + # - NEXTCLOUD_ADDITIONAL_APKS=imagemagick # This allows to add additional packages to the Nextcloud container permanently. See https://github.com/nextcloud/all-in-one#how-to-add-packets-permanently-to-the-nextcloud-container # - NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS=imagick # This allows to add additional php extensions to the Nextcloud container permanently. Default is imagick but can be overwritten by modifying this value. See https://github.com/nextcloud/all-in-one#how-to-add-php-extensions-permanently-to-the-nextcloud-container # # Optional: Caddy reverse proxy. See https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md diff --git a/manual-install/update-yaml.sh b/manual-install/update-yaml.sh index 50f60fd2..6e77ddd4 100644 --- a/manual-install/update-yaml.sh +++ b/manual-install/update-yaml.sh @@ -77,7 +77,7 @@ sed -i 's|NEXTCLOUD_PASSWORD=|NEXTCLOUD_PASSWORD= # TODO! This is the p sed -i 's|TIMEZONE=|TIMEZONE=Europe/Berlin # TODO! This is the timezone that your containers will use.|' sample.conf sed -i 's|COLLABORA_SECCOMP_POLICY=|COLLABORA_SECCOMP_POLICY=--o:security.seccomp=true # Changing the value to false allows to disable the seccomp feature of the Collabora container.|' sample.conf sed -i 's|NEXTCLOUD_STARTUP_APPS=|NEXTCLOUD_STARTUP_APPS=twofactor_totp deck tasks calendar contacts apporder # Allows to modify the Nextcloud apps that are installed on starting AIO the first time|' sample.conf -sed -i 's|NEXTCLOUD_ADDITIONAL_APKS=|NEXTCLOUD_ADDITIONAL_APKS=imagick # This allows to add additional packages to the Nextcloud container permanently.|' sample.conf +sed -i 's|NEXTCLOUD_ADDITIONAL_APKS=|NEXTCLOUD_ADDITIONAL_APKS=imagemagick # This allows to add additional packages to the Nextcloud container permanently.|' sample.conf sed -i 's|NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS=|NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS=imagick # This allows to add additional php extensions to the Nextcloud container permanently. Default is imagick but can be overwritten by modifying this value.|' sample.conf sed -i 's|=$|= # TODO! This needs to be a unique and good password!|' sample.conf diff --git a/php/src/Data/ConfigurationManager.php b/php/src/Data/ConfigurationManager.php index fb0a986a..a9b209e9 100644 --- a/php/src/Data/ConfigurationManager.php +++ b/php/src/Data/ConfigurationManager.php @@ -564,7 +564,7 @@ class ConfigurationManager public function GetNextcloudAdditionalApks() : string { $envVariableName = 'NEXTCLOUD_ADDITIONAL_APKS'; $configName = 'nextcloud_additional_apks'; - $defaultValue = ''; + $defaultValue = 'imagemagick'; return trim($this->GetEnvironmentalVariableOrConfig($envVariableName, $configName, $defaultValue)); } diff --git a/readme.md b/readme.md index 220e8773..cbcd5ea9 100644 --- a/readme.md +++ b/readme.md @@ -470,7 +470,7 @@ You might want to adjust the Nextcloud apps that are installed upon the first st ### How to add packets permanently to the Nextcloud container? Some Nextcloud apps require additional external dependencies that must be bundled within Nextcloud container in order to work correctly. As we cannot put each and every dependency for all apps into the container - as this would make the project very fast unmaintainable - there is an official way how you can add additional dependencies into the Nextcloud container. However note that doing this is not recommended since we do not test Nextcloud apps that require external dependencies. -You can do so by adding `-e NEXTCLOUD_ADDITIONAL_APKS="dependency1 dependency2"` to the docker run command of the mastercontainer and customize the value to your fitting. It must be a string with small letters a-z, spaces and hyphens or '_'. You can find available packages here: https://pkgs.alpinelinux.org/packages?name=&branch=v3.16&repo=&arch=&maintainer= +You can do so by adding `-e NEXTCLOUD_ADDITIONAL_APKS="imagemagick dependency2 dependency3"` to the docker run command of the mastercontainer and customize the value to your fitting. It must be a string with small letters a-z, spaces and hyphens or '_'. You can find available packages here: https://pkgs.alpinelinux.org/packages?name=&branch=v3.16&repo=&arch=&maintainer=. By default added is `imagemagick`. If you want to keep that, you need to specify it as well. ### How to add PHP extensions permanently to the Nextcloud container? Some Nextcloud apps require additional php extensions that must be bundled within Nextcloud container in order to work correctly. As we cannot put each and every dependency for all apps into the container - as this would make the project very fast unmaintainable - there is an official way how you can add additional php extensions into the Nextcloud container. However note that doing this is not recommended since we do not test Nextcloud apps that require additional php extensions. diff --git a/tests/QA/060-environmental-variables.md b/tests/QA/060-environmental-variables.md index 0b8e70a9..63a37502 100644 --- a/tests/QA/060-environmental-variables.md +++ b/tests/QA/060-environmental-variables.md @@ -16,7 +16,7 @@ See https://github.com/nextcloud/all-in-one#how-to-trust-user-defiend-certification-authorities-ca - [ ] When starting the mastercontainer with `-e COLLABORA_SECCOMP_DISABLED=true`, the resulting collabora container should have `--o:security.seccomp=false` applied to it. - [ ] When starting the mastercontainer with `-e NEXTCLOUD_STARTUP_APPS=deck`, the resulting Nextcloud should have only installed the deck app and not the other apps that get installed by default. Default are `twofactor_totp deck tasks calendar contacts apporder`. -- [ ] When starting the mastercontainer with `-e NEXTCLOUD_ADDITIONAL_APKS=zip`, the resulting Nextcloud container should have the zip package installed. +- [ ] When starting the mastercontainer with `-e NEXTCLOUD_ADDITIONAL_APKS=zip`, the resulting Nextcloud container should have the zip package installed and not imagemagick. - [ ] When starting the mastercontainer with `-e NEXTCLOUD_ADDITIONAL_PHP_EXTENSIONS=inotify`, the resulting Nextcloud container should have the inotify extension installed and not the imagick extension. You can now continue with [070-timezone-change.md](./070-timezone-change.md)