0
0
Fork 0
mirror of https://github.com/nextcloud/docker.git synced 2025-03-15 19:05:09 +01:00

Add NEXTCLOUD_BASE_DIR option

Signed-off-by: pierre <pierre.m@nikolov.fr>
This commit is contained in:
pierre 2019-03-12 14:50:10 +01:00 committed by pierre
parent bcd2e52e11
commit a6fb05ffa5
22 changed files with 248 additions and 122 deletions

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-debian.template # DO NOT EDIT: created by update.sh from Dockerfile-debian.template
FROM php:7.2-apache-stretch FROM php:7.2-apache-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -13,7 +15,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
RUN a2enmod rewrite remoteip ;\ RUN a2enmod rewrite remoteip ;\
{\ {\

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template
FROM php:7.2-fpm-alpine3.9 FROM php:7.2-fpm-alpine3.9
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -9,7 +11,7 @@ RUN set -ex; \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
ENV NEXTCLOUD_VERSION 13.0.12 ENV NEXTCLOUD_VERSION 13.0.12

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-debian.template # DO NOT EDIT: created by update.sh from Dockerfile-debian.template
FROM php:7.2-fpm-stretch FROM php:7.2-fpm-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -13,7 +15,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
ENV NEXTCLOUD_VERSION 13.0.12 ENV NEXTCLOUD_VERSION 13.0.12

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-debian.template # DO NOT EDIT: created by update.sh from Dockerfile-debian.template
FROM php:7.2-apache-stretch FROM php:7.2-apache-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -13,7 +15,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
RUN a2enmod rewrite remoteip ;\ RUN a2enmod rewrite remoteip ;\
{\ {\

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template
FROM php:7.2-fpm-alpine3.9 FROM php:7.2-fpm-alpine3.9
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -9,7 +11,7 @@ RUN set -ex; \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
ENV NEXTCLOUD_VERSION 14.0.8 ENV NEXTCLOUD_VERSION 14.0.8

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-debian.template # DO NOT EDIT: created by update.sh from Dockerfile-debian.template
FROM php:7.2-fpm-stretch FROM php:7.2-fpm-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -13,7 +15,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
ENV NEXTCLOUD_VERSION 14.0.8 ENV NEXTCLOUD_VERSION 14.0.8

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-debian.template # DO NOT EDIT: created by update.sh from Dockerfile-debian.template
FROM php:7.2-apache-stretch FROM php:7.2-apache-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -13,7 +15,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
RUN a2enmod rewrite remoteip ;\ RUN a2enmod rewrite remoteip ;\
{\ {\

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template
FROM php:7.2-fpm-alpine3.9 FROM php:7.2-fpm-alpine3.9
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -9,7 +11,7 @@ RUN set -ex; \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
ENV NEXTCLOUD_VERSION 15.0.5 ENV NEXTCLOUD_VERSION 15.0.5

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,6 +1,8 @@
# DO NOT EDIT: created by update.sh from Dockerfile-debian.template # DO NOT EDIT: created by update.sh from Dockerfile-debian.template
FROM php:7.2-fpm-stretch FROM php:7.2-fpm-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -13,7 +15,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
ENV NEXTCLOUD_VERSION 15.0.5 ENV NEXTCLOUD_VERSION 15.0.5

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after

View file

@ -1,5 +1,7 @@
FROM php:%%PHP_VERSION%%-%%VARIANT%%3.9 FROM php:%%PHP_VERSION%%-%%VARIANT%%3.9
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -8,7 +10,7 @@ RUN set -ex; \
; \ ; \
\ \
rm /var/spool/cron/crontabs/root; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
%%VARIANT_EXTRAS%% %%VARIANT_EXTRAS%%
ENV NEXTCLOUD_VERSION %%VERSION%% ENV NEXTCLOUD_VERSION %%VERSION%%

View file

@ -1,5 +1,7 @@
FROM php:%%PHP_VERSION%%-%%VARIANT%%-stretch FROM php:%%PHP_VERSION%%-%%VARIANT%%-stretch
ENV NEXTCLOUD_BASE_DIR /var/www/html
# entrypoint.sh and cron.sh dependencies # entrypoint.sh and cron.sh dependencies
RUN set -ex; \ RUN set -ex; \
\ \
@ -12,7 +14,7 @@ RUN set -ex; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
\ \
mkdir -p /var/spool/cron/crontabs; \ 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 # install the PHP extensions we need
# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html # 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; \ chown -R www-data:root /var/www; \
chmod -R g=u /var/www chmod -R g=u /var/www
VOLUME /var/www/html VOLUME ${NEXTCLOUD_BASE_DIR}
%%VARIANT_EXTRAS%% %%VARIANT_EXTRAS%%
ENV NEXTCLOUD_VERSION %%VERSION%% ENV NEXTCLOUD_VERSION %%VERSION%%

View file

@ -117,6 +117,10 @@ If you set any values, they will not be asked in the install page on first run.
- `NEXTCLOUD_ADMIN_USER` Name of the Nextcloud admin user. - `NEXTCLOUD_ADMIN_USER` Name of the Nextcloud admin user.
- `NEXTCLOUD_ADMIN_PASSWORD` Password for the Nextcloud admin user. - `NEXTCLOUD_ADMIN_PASSWORD` Password for the Nextcloud admin user.
If you want you can set the data based directory, otherwise default values will be used.
- `NEXTCLOUD_BASE_DIR` (default: _/var/www/html_) Configures the base directory where nextcloud will be installed in the docker container.
If you want you can set the data directory and table prefix, otherwise default values will be used. If you want you can set the data directory and table prefix, otherwise default values will be used.
- `NEXTCLOUD_DATA_DIR` (default: _/var/www/html/data_) Configures the data directory where nextcloud stores all files from the users. - `NEXTCLOUD_DATA_DIR` (default: _/var/www/html/data_) Configures the data directory where nextcloud stores all files from the users.

View file

@ -19,11 +19,21 @@ run_as() {
fi 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 if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then
installed_version="0.0.0.0" 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 # 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 fi
# shellcheck disable=SC2016 # shellcheck disable=SC2016
image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" 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 ..." echo "Initializing nextcloud $image_version ..."
if [ "$installed_version" != "0.0.0.0" ]; then if [ "$installed_version" != "0.0.0.0" ]; then
echo "Upgrading nextcloud from $installed_version ..." 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 fi
if [ "$(id -u)" = 0 ]; then if [ "$(id -u)" = 0 ]; then
rsync_options="-rlDog --chown www-data:root" rsync_options="-rlDog --chown www-data:root"
else else
rsync_options="-rlD" rsync_options="-rlD"
fi 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 for dir in config data custom_apps themes; do
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then if [ ! -d "$NEXTCLOUD_BASE_DIR/$dir" ] || directory_empty "$NEXTCLOUD_BASE_DIR/$dir"; then
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ $NEXTCLOUD_BASE_DIR/
fi fi
done done
echo "Initializing finished" echo "Initializing finished"
@ -93,7 +103,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
echo "starting nextcloud installation" echo "starting nextcloud installation"
max_retries=10 max_retries=10
try=0 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 do
echo "retrying install..." echo "retrying install..."
try=$((try+1)) try=$((try+1))
@ -108,7 +118,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
NC_TRUSTED_DOMAIN_IDX=1 NC_TRUSTED_DOMAIN_IDX=1
for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do
DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') 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)) NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1))
done done
fi fi
@ -118,9 +128,9 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
fi fi
#upgrade #upgrade
else 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:" echo "The following apps have been disabled:"
diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1
rm -f /tmp/list_before /tmp/list_after rm -f /tmp/list_before /tmp/list_after