diff --git a/16.0-alpha/apache/Dockerfile b/16.0-alpha/apache/Dockerfile index a06f4d1d..f70f2a24 100644 --- a/16.0-alpha/apache/Dockerfile +++ b/16.0-alpha/apache/Dockerfile @@ -1,6 +1,8 @@ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:7.2-apache-stretch +ENV NEXTCLOUD_BASE_DIR /var/www/html + # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -13,7 +15,7 @@ RUN set -ex; \ rm -rf /var/lib/apt/lists/*; \ \ mkdir -p /var/spool/cron/crontabs; \ - echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + echo '*/15 * * * * php -f ${NEXTCLOUD_BASE_DIR}/cron.php' > /var/spool/cron/crontabs/www-data # install the PHP extensions we need # see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html @@ -99,7 +101,7 @@ RUN { \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www -VOLUME /var/www/html +VOLUME ${NEXTCLOUD_BASE_DIR} RUN a2enmod rewrite remoteip ;\ {\ diff --git a/16.0-alpha/apache/entrypoint.sh b/16.0-alpha/apache/entrypoint.sh index 6ef2540e..82f37879 100755 --- a/16.0-alpha/apache/entrypoint.sh +++ b/16.0-alpha/apache/entrypoint.sh @@ -19,11 +19,21 @@ run_as() { fi } +if [ -z "${NEXTCLOUD_BASE_DIR}" ]; then + NEXTCLOUD_BASE_DIR='/var/www/html' +else + mkdir -p $NEXTCLOUD_BASE_DIR + if [ -f /usr/sbin/apache2ctl ]; then + sed -i "s,$NEXTCLOUD_BASE_DIR,$NEXTCLOUD_BASE_DIR/nextcloud,g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s,/var/www/html,$NEXTCLOUD_BASE_DIR,g" /etc/apache2/sites-available/000-default.conf + fi +fi + 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 + if [ -f $NEXTCLOUD_BASE_DIR/version.php ]; then # shellcheck disable=SC2016 - installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + installed_version="$(php -r 'require "$NEXTCLOUD_BASE_DIR/version.php"; echo implode(".", $OC_Version);')" fi # shellcheck disable=SC2016 image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" @@ -37,18 +47,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then echo "Upgrading nextcloud from $installed_version ..." - run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + run_as "php $NEXTCLOUD_BASE_DIR/occ app:list" | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before fi if [ "$(id -u)" = 0 ]; then rsync_options="-rlDog --chown www-data:root" else rsync_options="-rlD" fi - rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/ for dir in config data custom_apps themes; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/ fi done rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ @@ -94,7 +104,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "starting nextcloud installation" max_retries=10 try=0 - until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + until run_as "php $NEXTCLOUD_BASE_DIR/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do echo "retrying install..." try=$((try+1)) @@ -109,7 +119,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=1 for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') - run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + run_as "php $NEXTCLOUD_BASE_DIR/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi @@ -119,9 +129,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi #upgrade else - run_as 'php /var/www/html/occ upgrade' + run_as "php $NEXTCLOUD_BASE_DIR/occ upgrade" - run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + run_as "php $NEXTCLOUD_BASE_DIR/occ app:list" | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after diff --git a/16.0-alpha/fpm-alpine/Dockerfile b/16.0-alpha/fpm-alpine/Dockerfile index fdd23409..ab069523 100644 --- a/16.0-alpha/fpm-alpine/Dockerfile +++ b/16.0-alpha/fpm-alpine/Dockerfile @@ -1,6 +1,8 @@ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template FROM php:7.2-fpm-alpine3.9 +ENV NEXTCLOUD_BASE_DIR /var/www/html + # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -9,7 +11,7 @@ RUN set -ex; \ ; \ \ rm /var/spool/cron/crontabs/root; \ - echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + echo '*/15 * * * * php -f ${NEXTCLOUD_BASE_DIR}/cron.php' > /var/spool/cron/crontabs/www-data # install the PHP extensions we need # see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html @@ -88,7 +90,7 @@ RUN { \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www -VOLUME /var/www/html +VOLUME ${NEXTCLOUD_BASE_DIR} ENV NEXTCLOUD_VERSION 16.0.0alpha1 diff --git a/16.0-alpha/fpm-alpine/entrypoint.sh b/16.0-alpha/fpm-alpine/entrypoint.sh index 6ef2540e..82f37879 100755 --- a/16.0-alpha/fpm-alpine/entrypoint.sh +++ b/16.0-alpha/fpm-alpine/entrypoint.sh @@ -19,11 +19,21 @@ run_as() { fi } +if [ -z "${NEXTCLOUD_BASE_DIR}" ]; then + NEXTCLOUD_BASE_DIR='/var/www/html' +else + mkdir -p $NEXTCLOUD_BASE_DIR + if [ -f /usr/sbin/apache2ctl ]; then + sed -i "s,$NEXTCLOUD_BASE_DIR,$NEXTCLOUD_BASE_DIR/nextcloud,g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s,/var/www/html,$NEXTCLOUD_BASE_DIR,g" /etc/apache2/sites-available/000-default.conf + fi +fi + 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 + if [ -f $NEXTCLOUD_BASE_DIR/version.php ]; then # shellcheck disable=SC2016 - installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + installed_version="$(php -r 'require "$NEXTCLOUD_BASE_DIR/version.php"; echo implode(".", $OC_Version);')" fi # shellcheck disable=SC2016 image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" @@ -37,18 +47,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then echo "Upgrading nextcloud from $installed_version ..." - run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + run_as "php $NEXTCLOUD_BASE_DIR/occ app:list" | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before fi if [ "$(id -u)" = 0 ]; then rsync_options="-rlDog --chown www-data:root" else rsync_options="-rlD" fi - rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/ for dir in config data custom_apps themes; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/ fi done rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ @@ -94,7 +104,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "starting nextcloud installation" max_retries=10 try=0 - until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + until run_as "php $NEXTCLOUD_BASE_DIR/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do echo "retrying install..." try=$((try+1)) @@ -109,7 +119,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=1 for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') - run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + run_as "php $NEXTCLOUD_BASE_DIR/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi @@ -119,9 +129,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi #upgrade else - run_as 'php /var/www/html/occ upgrade' + run_as "php $NEXTCLOUD_BASE_DIR/occ upgrade" - run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + run_as "php $NEXTCLOUD_BASE_DIR/occ app:list" | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after diff --git a/16.0-alpha/fpm/Dockerfile b/16.0-alpha/fpm/Dockerfile index b9ff14e6..a4013055 100644 --- a/16.0-alpha/fpm/Dockerfile +++ b/16.0-alpha/fpm/Dockerfile @@ -1,6 +1,8 @@ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:7.2-fpm-stretch +ENV NEXTCLOUD_BASE_DIR /var/www/html + # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ @@ -13,7 +15,7 @@ RUN set -ex; \ rm -rf /var/lib/apt/lists/*; \ \ mkdir -p /var/spool/cron/crontabs; \ - echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + echo '*/15 * * * * php -f ${NEXTCLOUD_BASE_DIR}/cron.php' > /var/spool/cron/crontabs/www-data # install the PHP extensions we need # see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html @@ -99,7 +101,7 @@ RUN { \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www -VOLUME /var/www/html +VOLUME ${NEXTCLOUD_BASE_DIR} ENV NEXTCLOUD_VERSION 16.0.0alpha1 diff --git a/16.0-alpha/fpm/entrypoint.sh b/16.0-alpha/fpm/entrypoint.sh index 6ef2540e..82f37879 100755 --- a/16.0-alpha/fpm/entrypoint.sh +++ b/16.0-alpha/fpm/entrypoint.sh @@ -19,11 +19,21 @@ run_as() { fi } +if [ -z "${NEXTCLOUD_BASE_DIR}" ]; then + NEXTCLOUD_BASE_DIR='/var/www/html' +else + mkdir -p $NEXTCLOUD_BASE_DIR + if [ -f /usr/sbin/apache2ctl ]; then + sed -i "s,$NEXTCLOUD_BASE_DIR,$NEXTCLOUD_BASE_DIR/nextcloud,g" /etc/apache2/sites-available/default-ssl.conf + sed -i "s,/var/www/html,$NEXTCLOUD_BASE_DIR,g" /etc/apache2/sites-available/000-default.conf + fi +fi + 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 + if [ -f $NEXTCLOUD_BASE_DIR/version.php ]; then # shellcheck disable=SC2016 - installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + installed_version="$(php -r 'require "$NEXTCLOUD_BASE_DIR/version.php"; echo implode(".", $OC_Version);')" fi # shellcheck disable=SC2016 image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" @@ -37,18 +47,18 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "Initializing nextcloud $image_version ..." if [ "$installed_version" != "0.0.0.0" ]; then echo "Upgrading nextcloud from $installed_version ..." - run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + run_as "php $NEXTCLOUD_BASE_DIR/occ app:list" | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before fi if [ "$(id -u)" = 0 ]; then rsync_options="-rlDog --chown www-data:root" else rsync_options="-rlD" fi - rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/ for dir in config data custom_apps themes; do - if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then - rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/ fi done rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ @@ -94,7 +104,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP echo "starting nextcloud installation" max_retries=10 try=0 - until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + until run_as "php $NEXTCLOUD_BASE_DIR/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] do echo "retrying install..." try=$((try+1)) @@ -109,7 +119,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP NC_TRUSTED_DOMAIN_IDX=1 for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') - run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + run_as "php $NEXTCLOUD_BASE_DIR/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) done fi @@ -119,9 +129,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi #upgrade else - run_as 'php /var/www/html/occ upgrade' + run_as "php $NEXTCLOUD_BASE_DIR/occ upgrade" - run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + run_as "php $NEXTCLOUD_BASE_DIR/occ app:list" | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after echo "The following apps have been disabled:" diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 rm -f /tmp/list_before /tmp/list_after