From 0c7ef56635492a2d1be6eda74b7e63a22434b30b Mon Sep 17 00:00:00 2001 From: Roland Vet Date: Tue, 6 Apr 2021 12:56:35 +0200 Subject: [PATCH 1/4] Replace crond with a while loop. Adding the cron command to /var/spool/cron/crontabs/www-data assumes that cron, and by extension the nextcloud app, is run as 'www-data'. 'crond' cannot be used with: exec "echo \"*/%%CRONTAB_INT%% * * * * php -f /var/www/html/cron.php\" | crontab - && crond -f -l 0 -L /dev/stdout" because that assumes the uid used matches a entry in '/etc/passwd'. Signed-off-by: Roland Vet --- Dockerfile-alpine.template | 3 +-- Dockerfile-debian.template | 5 +---- docker-cron.sh | 5 ++++- update.sh | 5 ++++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 4d05f14d..b7afed9c 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -7,8 +7,7 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root; \ - echo '*/%%CRONTAB_INT%% * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + rm /var/spool/cron/crontabs/root # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index e6c48d54..26b00dbb 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -10,10 +10,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/*; \ - \ - mkdir -p /var/spool/cron/crontabs; \ - echo '*/%%CRONTAB_INT%% * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + 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 diff --git a/docker-cron.sh b/docker-cron.sh index 4dfa4118..d38ea81f 100755 --- a/docker-cron.sh +++ b/docker-cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep %%CRONTAB_INT%%m; +done diff --git a/update.sh b/update.sh index e293a800..bda4bba5 100755 --- a/update.sh +++ b/update.sh @@ -111,7 +111,6 @@ function create_variant() { s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g; s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g; s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g; - s/%%CRONTAB_INT%%/'"$crontabInt"'/g; ' "$dir/Dockerfile" case "$phpVersion" in @@ -132,6 +131,10 @@ function create_variant() { for name in entrypoint cron; do cp "docker-$name.sh" "$dir/$name.sh" done + # Replace the variable. + sed -ri -e ' + s/%%CRONTAB_INT%%/'"$crontabInt"'/g; + ' "$dir/cron.sh" # Copy the upgrade.exclude cp upgrade.exclude "$dir/" From 64f040b44d2fa7f947b268470accd181dad36f59 Mon Sep 17 00:00:00 2001 From: Roland Vet Date: Tue, 6 Apr 2021 13:35:08 +0200 Subject: [PATCH 2/4] Runs update.sh Signed-off-by: Roland Vet --- 20/apache/Dockerfile | 5 +---- 20/apache/cron.sh | 5 ++++- 20/fpm-alpine/Dockerfile | 3 +-- 20/fpm-alpine/cron.sh | 5 ++++- 20/fpm/Dockerfile | 5 +---- 20/fpm/cron.sh | 5 ++++- 21/apache/Dockerfile | 5 +---- 21/apache/cron.sh | 5 ++++- 21/fpm-alpine/Dockerfile | 3 +-- 21/fpm-alpine/cron.sh | 5 ++++- 21/fpm/Dockerfile | 5 +---- 21/fpm/cron.sh | 5 ++++- 22/apache/Dockerfile | 5 +---- 22/apache/cron.sh | 5 ++++- 22/fpm-alpine/Dockerfile | 3 +-- 22/fpm-alpine/cron.sh | 5 ++++- 22/fpm/Dockerfile | 5 +---- 22/fpm/cron.sh | 5 ++++- 18 files changed, 45 insertions(+), 39 deletions(-) diff --git a/20/apache/Dockerfile b/20/apache/Dockerfile index 04367919..0d9fe0e9 100644 --- a/20/apache/Dockerfile +++ b/20/apache/Dockerfile @@ -11,10 +11,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - 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 + 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 diff --git a/20/apache/cron.sh b/20/apache/cron.sh index 4dfa4118..b7ac9597 100755 --- a/20/apache/cron.sh +++ b/20/apache/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/20/fpm-alpine/Dockerfile b/20/fpm-alpine/Dockerfile index 9453bca5..4648c3f8 100644 --- a/20/fpm-alpine/Dockerfile +++ b/20/fpm-alpine/Dockerfile @@ -8,8 +8,7 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root; \ - echo '*/5 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + rm /var/spool/cron/crontabs/root # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/20/fpm-alpine/cron.sh b/20/fpm-alpine/cron.sh index 4dfa4118..b7ac9597 100755 --- a/20/fpm-alpine/cron.sh +++ b/20/fpm-alpine/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/20/fpm/Dockerfile b/20/fpm/Dockerfile index e3255c80..55d5876d 100644 --- a/20/fpm/Dockerfile +++ b/20/fpm/Dockerfile @@ -11,10 +11,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - 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 + 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 diff --git a/20/fpm/cron.sh b/20/fpm/cron.sh index 4dfa4118..b7ac9597 100755 --- a/20/fpm/cron.sh +++ b/20/fpm/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/21/apache/Dockerfile b/21/apache/Dockerfile index b47234f3..9cb86d88 100644 --- a/21/apache/Dockerfile +++ b/21/apache/Dockerfile @@ -11,10 +11,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - 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 + 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 diff --git a/21/apache/cron.sh b/21/apache/cron.sh index 4dfa4118..b7ac9597 100755 --- a/21/apache/cron.sh +++ b/21/apache/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/21/fpm-alpine/Dockerfile b/21/fpm-alpine/Dockerfile index 1ccf31b0..cfb09863 100644 --- a/21/fpm-alpine/Dockerfile +++ b/21/fpm-alpine/Dockerfile @@ -8,8 +8,7 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root; \ - echo '*/5 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + rm /var/spool/cron/crontabs/root # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/21/fpm-alpine/cron.sh b/21/fpm-alpine/cron.sh index 4dfa4118..b7ac9597 100755 --- a/21/fpm-alpine/cron.sh +++ b/21/fpm-alpine/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/21/fpm/Dockerfile b/21/fpm/Dockerfile index f769fc68..0fc9a3ea 100644 --- a/21/fpm/Dockerfile +++ b/21/fpm/Dockerfile @@ -11,10 +11,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - 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 + 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 diff --git a/21/fpm/cron.sh b/21/fpm/cron.sh index 4dfa4118..b7ac9597 100755 --- a/21/fpm/cron.sh +++ b/21/fpm/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/22/apache/Dockerfile b/22/apache/Dockerfile index 90f0fb85..61d6fefb 100644 --- a/22/apache/Dockerfile +++ b/22/apache/Dockerfile @@ -11,10 +11,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - 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 + 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 diff --git a/22/apache/cron.sh b/22/apache/cron.sh index 4dfa4118..b7ac9597 100755 --- a/22/apache/cron.sh +++ b/22/apache/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/22/fpm-alpine/Dockerfile b/22/fpm-alpine/Dockerfile index 98ceb949..42a1f632 100644 --- a/22/fpm-alpine/Dockerfile +++ b/22/fpm-alpine/Dockerfile @@ -8,8 +8,7 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root; \ - echo '*/5 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + rm /var/spool/cron/crontabs/root # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/22/fpm-alpine/cron.sh b/22/fpm-alpine/cron.sh index 4dfa4118..b7ac9597 100755 --- a/22/fpm-alpine/cron.sh +++ b/22/fpm-alpine/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done diff --git a/22/fpm/Dockerfile b/22/fpm/Dockerfile index 8fde133f..2f146886 100644 --- a/22/fpm/Dockerfile +++ b/22/fpm/Dockerfile @@ -11,10 +11,7 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - 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 + 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 diff --git a/22/fpm/cron.sh b/22/fpm/cron.sh index 4dfa4118..b7ac9597 100755 --- a/22/fpm/cron.sh +++ b/22/fpm/cron.sh @@ -1,4 +1,7 @@ #!/bin/sh set -eu -exec busybox crond -f -l 0 -L /dev/stdout +while [ 1 ]; do + (php -f /var/www/html/cron.php &); + sleep 5m; +done From 1a22f36b72411b2124a8f3b6655eebe70994d3e6 Mon Sep 17 00:00:00 2001 From: Roland Vet Date: Tue, 6 Apr 2021 13:02:12 +0200 Subject: [PATCH 3/4] Make redis-session.ini writable by non-root. If "REDIS_HOST=redis" is used in combination with a custom uid, the container attempts to write to redis-session.ini which fails due to lack of permission. Signed-off-by: Roland Vet --- Dockerfile-alpine.template | 4 +++- Dockerfile-debian.template | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index b7afed9c..0cc55e86 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -7,7 +7,9 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root + rm /var/spool/cron/crontabs/root; \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 26b00dbb..f27c82e0 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -10,7 +10,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html From 47610bb7de468711c95a306424b76e497408950f Mon Sep 17 00:00:00 2001 From: Roland Vet Date: Tue, 6 Apr 2021 13:36:15 +0200 Subject: [PATCH 4/4] Runs update.sh Signed-off-by: Roland Vet --- 20/apache/Dockerfile | 5 ++++- 20/fpm-alpine/Dockerfile | 4 +++- 20/fpm/Dockerfile | 5 ++++- 21/apache/Dockerfile | 5 ++++- 21/fpm-alpine/Dockerfile | 4 +++- 21/fpm/Dockerfile | 5 ++++- 22/apache/Dockerfile | 5 ++++- 22/fpm-alpine/Dockerfile | 4 +++- 22/fpm/Dockerfile | 5 ++++- 9 files changed, 33 insertions(+), 9 deletions(-) diff --git a/20/apache/Dockerfile b/20/apache/Dockerfile index 0d9fe0e9..cf65ec5e 100644 --- a/20/apache/Dockerfile +++ b/20/apache/Dockerfile @@ -11,7 +11,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/20/fpm-alpine/Dockerfile b/20/fpm-alpine/Dockerfile index 4648c3f8..ea4c6fe7 100644 --- a/20/fpm-alpine/Dockerfile +++ b/20/fpm-alpine/Dockerfile @@ -8,7 +8,9 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root + rm /var/spool/cron/crontabs/root; \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/20/fpm/Dockerfile b/20/fpm/Dockerfile index 55d5876d..98d64418 100644 --- a/20/fpm/Dockerfile +++ b/20/fpm/Dockerfile @@ -11,7 +11,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/21/apache/Dockerfile b/21/apache/Dockerfile index 9cb86d88..3cd73017 100644 --- a/21/apache/Dockerfile +++ b/21/apache/Dockerfile @@ -11,7 +11,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/21/fpm-alpine/Dockerfile b/21/fpm-alpine/Dockerfile index cfb09863..e5b92a0d 100644 --- a/21/fpm-alpine/Dockerfile +++ b/21/fpm-alpine/Dockerfile @@ -8,7 +8,9 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root + rm /var/spool/cron/crontabs/root; \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/21/fpm/Dockerfile b/21/fpm/Dockerfile index 0fc9a3ea..93958633 100644 --- a/21/fpm/Dockerfile +++ b/21/fpm/Dockerfile @@ -11,7 +11,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/22/apache/Dockerfile b/22/apache/Dockerfile index 61d6fefb..2cab1f10 100644 --- a/22/apache/Dockerfile +++ b/22/apache/Dockerfile @@ -11,7 +11,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/22/fpm-alpine/Dockerfile b/22/fpm-alpine/Dockerfile index 42a1f632..0569d920 100644 --- a/22/fpm-alpine/Dockerfile +++ b/22/fpm-alpine/Dockerfile @@ -8,7 +8,9 @@ RUN set -ex; \ rsync \ ; \ \ - rm /var/spool/cron/crontabs/root + rm /var/spool/cron/crontabs/root; \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html diff --git a/22/fpm/Dockerfile b/22/fpm/Dockerfile index 2f146886..82d9f825 100644 --- a/22/fpm/Dockerfile +++ b/22/fpm/Dockerfile @@ -11,7 +11,10 @@ RUN set -ex; \ busybox-static \ libldap-common \ ; \ - rm -rf /var/lib/apt/lists/* + rm -rf /var/lib/apt/lists/*; \ + \ + touch /usr/local/etc/php/conf.d/redis-session.ini; \ + chmod o+rw /usr/local/etc/php/conf.d/redis-session.ini; # install the PHP extensions we need # see https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html