diff --git a/13.0/apache/Dockerfile b/13.0/apache/Dockerfile index 2a3ba93e..935e5906 100644 --- a/13.0/apache/Dockerfile +++ b/13.0/apache/Dockerfile @@ -89,12 +89,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html RUN a2enmod rewrite remoteip ;\ diff --git a/13.0/apache/entrypoint.sh b/13.0/apache/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/13.0/apache/entrypoint.sh +++ b/13.0/apache/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/13.0/fpm-alpine/Dockerfile b/13.0/fpm-alpine/Dockerfile index 9f22e0f2..788b0c07 100644 --- a/13.0/fpm-alpine/Dockerfile +++ b/13.0/fpm-alpine/Dockerfile @@ -78,12 +78,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html diff --git a/13.0/fpm-alpine/entrypoint.sh b/13.0/fpm-alpine/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/13.0/fpm-alpine/entrypoint.sh +++ b/13.0/fpm-alpine/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/13.0/fpm/Dockerfile b/13.0/fpm/Dockerfile index 8ec966da..a89b86a8 100644 --- a/13.0/fpm/Dockerfile +++ b/13.0/fpm/Dockerfile @@ -89,12 +89,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html diff --git a/13.0/fpm/entrypoint.sh b/13.0/fpm/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/13.0/fpm/entrypoint.sh +++ b/13.0/fpm/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/14.0/apache/Dockerfile b/14.0/apache/Dockerfile index 9ac1e34a..b9d5664e 100644 --- a/14.0/apache/Dockerfile +++ b/14.0/apache/Dockerfile @@ -89,12 +89,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html RUN a2enmod rewrite remoteip ;\ diff --git a/14.0/apache/entrypoint.sh b/14.0/apache/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/14.0/apache/entrypoint.sh +++ b/14.0/apache/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/14.0/fpm-alpine/Dockerfile b/14.0/fpm-alpine/Dockerfile index 87dd98ce..4790e9f7 100644 --- a/14.0/fpm-alpine/Dockerfile +++ b/14.0/fpm-alpine/Dockerfile @@ -78,12 +78,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html diff --git a/14.0/fpm-alpine/entrypoint.sh b/14.0/fpm-alpine/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/14.0/fpm-alpine/entrypoint.sh +++ b/14.0/fpm-alpine/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/14.0/fpm/Dockerfile b/14.0/fpm/Dockerfile index 966c4be3..d523791c 100644 --- a/14.0/fpm/Dockerfile +++ b/14.0/fpm/Dockerfile @@ -89,12 +89,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html diff --git a/14.0/fpm/entrypoint.sh b/14.0/fpm/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/14.0/fpm/entrypoint.sh +++ b/14.0/fpm/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/15.0/apache/Dockerfile b/15.0/apache/Dockerfile index 48f1195b..a707f270 100644 --- a/15.0/apache/Dockerfile +++ b/15.0/apache/Dockerfile @@ -89,12 +89,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html RUN a2enmod rewrite remoteip ;\ diff --git a/15.0/apache/entrypoint.sh b/15.0/apache/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/15.0/apache/entrypoint.sh +++ b/15.0/apache/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/15.0/fpm-alpine/Dockerfile b/15.0/fpm-alpine/Dockerfile index d015b235..08989f7c 100644 --- a/15.0/fpm-alpine/Dockerfile +++ b/15.0/fpm-alpine/Dockerfile @@ -78,12 +78,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html diff --git a/15.0/fpm-alpine/entrypoint.sh b/15.0/fpm-alpine/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/15.0/fpm-alpine/entrypoint.sh +++ b/15.0/fpm-alpine/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/15.0/fpm/Dockerfile b/15.0/fpm/Dockerfile index 6b2c696a..cda5e69e 100644 --- a/15.0/fpm/Dockerfile +++ b/15.0/fpm/Dockerfile @@ -89,12 +89,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html diff --git a/15.0/fpm/entrypoint.sh b/15.0/fpm/entrypoint.sh index 045227e8..b2fad09c 100755 --- a/15.0/fpm/entrypoint.sh +++ b/15.0/fpm/entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 6683f2b1..a88efe92 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -77,12 +77,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html %%VARIANT_EXTRAS%% diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 7f451512..68e9cab0 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -88,12 +88,17 @@ RUN { \ \ echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ \ - echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ - \ mkdir /var/www/data; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www +# Allow PHP memory_limit to be configurable. Touch the INI file and give open permissions so that +# the entrypoint script can modify it when the container is run by non-root users. +ENV PHP_MEMORY_LIMIT=512M +RUN true \ + && ini_file=/usr/local/etc/php/conf.d/memory-limit.ini \ + && touch "$ini_file" && chmod a+rw "$ini_file" + VOLUME /var/www/html %%VARIANT_EXTRAS%% diff --git a/README.md b/README.md index 0d712c01..010703fb 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,9 @@ The install and update script is only triggered when a default command is used ( - `NEXTCLOUD_UPDATE` (default: _0_) +The PHP `memory_limit` setting can be controlled by specifying the below environment variable. +- `PHP_MEMORY_LIMIT` (default: `512M`) # Running this image with docker-compose The easiest way to get a fully featured and functional setup is using a `docker-compose` file. There are too many different possibilities to setup your system, so here are only some examples what you have to look for. diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 045227e8..b2fad09c 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -19,6 +19,9 @@ run_as() { fi } +# Update PHP's memory limit based on environment variable specified to Docker +echo "memory_limit=$PHP_MEMORY_LIMIT" > /usr/local/etc/php/conf.d/memory-limit.ini + if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then installed_version="0.0.0.0" if [ -f /var/www/html/version.php ]; then