From: Thomas Bruederli Date: Sun, 4 Oct 2020 20:31:36 +0000 (+0200) Subject: Automatic updates on mounted/shared volume `/var/www/html` X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=58f49d19f73f9ce35f08a4fa04ff1430641a80b9;p=roundcube-roundcubemail-docker.git updates on mounted/shared volume `/var/www/html` - Include `rsync` and `composer.phar` in images - run `bin/installto.sh` and `composer.phar update` from entry point addresses issues #58, #96 and implements pull requests #65 and #101 --- diff --git a/apache/Dockerfile b/apache/Dockerfile index e1f2423..ce20473 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -45,6 +45,21 @@ RUN set -ex; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ rm -rf /var/lib/apt/lists/* +# installto.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + ; \ + rm -rf /var/lib/apt/lists/* + +# ... and composer.phar +ADD https://getcomposer.org/installer /tmp/composer-installer.php + +RUN php /tmp/composer-installer.php --install-dir=/usr/local/bin/; \ + rm /tmp/composer-installer.php + # enable mod_rewrite RUN a2enmod rewrite diff --git a/apache/docker-entrypoint.sh b/apache/docker-entrypoint.sh index 7757d1e..68df92c 100755 --- a/apache/docker-entrypoint.sh +++ b/apache/docker-entrypoint.sh @@ -4,6 +4,7 @@ # PWD=`pwd` if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then + # docroot is empty if ! [ -e index.php -a -e bin/installto.sh ]; then echo >&2 "roundcubemail not found in $PWD - copying now..." if [ "$(ls -A)" ]; then @@ -12,6 +13,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD" + # update Roundcube in docroot + else + INSTALLDIR=`pwd` + echo >&2 "roundcubemail found in $INSTALLDIR - installing update..." + (cd /usr/src/roundcubemail && bin/installto.sh -y $INSTALLDIR) + composer.phar update --no-dev fi if [ -f /run/secrets/roundcube_db_user ]; then @@ -89,8 +96,8 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then echo "include('$fn');" >> config/config.inc.php done - # initialize DB if not SQLite - echo "${ROUNDCUBEMAIL_DSNW}" | grep -q 'sqlite:' || bin/initdb.sh --dir=$PWD/SQL || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize databse. Please run $PWD/bin/initdb.sh manually." + # initialize or update DB + bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." else echo "WARNING: $PWD/config/config.inc.php already exists." echo "ROUNDCUBEMAIL_* environment variables have been ignored." diff --git a/fpm-alpine/Dockerfile b/fpm-alpine/Dockerfile index 7096de7..8537918 100644 --- a/fpm-alpine/Dockerfile +++ b/fpm-alpine/Dockerfile @@ -1,12 +1,13 @@ FROM php:7.3-fpm-alpine LABEL maintainer="Thomas Bruederli " -# entrypoint.sh and cron.sh dependencies +# entrypoint.sh and installto.sh dependencies RUN set -ex; \ \ apk add --no-cache \ bash \ coreutils \ + rsync \ tzdata RUN set -ex; \ @@ -43,6 +44,12 @@ RUN set -ex; \ apk add --virtual .roundcubemail-phpext-rundeps $runDeps; \ apk del .build-deps +# add composer.phar +ADD https://getcomposer.org/installer /tmp/composer-installer.php + +RUN php /tmp/composer-installer.php --install-dir=/usr/local/bin/; \ + rm /tmp/composer-installer.php + # expose these volumes VOLUME /var/roundcube/config VOLUME /var/roundcube/db diff --git a/fpm-alpine/docker-entrypoint.sh b/fpm-alpine/docker-entrypoint.sh index 733453e..78804ff 100755 --- a/fpm-alpine/docker-entrypoint.sh +++ b/fpm-alpine/docker-entrypoint.sh @@ -4,6 +4,7 @@ # PWD=`pwd` if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then + # docroot is empty if ! [ -e index.php -a -e bin/installto.sh ]; then echo >&2 "roundcubemail not found in $PWD - copying now..." if [ "$(ls -A)" ]; then @@ -12,6 +13,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD" + # update Roundcube in docroot + else + INSTALLDIR=`pwd` + echo >&2 "roundcubemail found in $INSTALLDIR - installing update..." + (cd /usr/src/roundcubemail && bin/installto.sh -y $INSTALLDIR) + composer.phar update --no-dev fi if [ -f /run/secrets/roundcube_db_user ]; then @@ -89,8 +96,8 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then echo "include('$fn');" >> config/config.inc.php done - # initialize DB if not SQLite - echo "${ROUNDCUBEMAIL_DSNW}" | grep -q 'sqlite:' || bin/initdb.sh --dir=$PWD/SQL || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize databse. Please run $PWD/bin/initdb.sh manually." + # initialize or update DB + bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." else echo "WARNING: $PWD/config/config.inc.php already exists." echo "ROUNDCUBEMAIL_* environment variables have been ignored." diff --git a/fpm/Dockerfile b/fpm/Dockerfile index 6b40889..bcb3a9a 100644 --- a/fpm/Dockerfile +++ b/fpm/Dockerfile @@ -45,6 +45,20 @@ RUN set -ex; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ rm -rf /var/lib/apt/lists/* +# installto.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + ; \ + rm -rf /var/lib/apt/lists/* + +# ... and composer.phar +ADD https://getcomposer.org/installer /tmp/composer-installer.php + +RUN php /tmp/composer-installer.php --install-dir=/usr/local/bin/; \ + rm /tmp/composer-installer.php # expose these volumes VOLUME /var/roundcube/config diff --git a/fpm/docker-entrypoint.sh b/fpm/docker-entrypoint.sh index 7757d1e..68df92c 100755 --- a/fpm/docker-entrypoint.sh +++ b/fpm/docker-entrypoint.sh @@ -4,6 +4,7 @@ # PWD=`pwd` if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then + # docroot is empty if ! [ -e index.php -a -e bin/installto.sh ]; then echo >&2 "roundcubemail not found in $PWD - copying now..." if [ "$(ls -A)" ]; then @@ -12,6 +13,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD" + # update Roundcube in docroot + else + INSTALLDIR=`pwd` + echo >&2 "roundcubemail found in $INSTALLDIR - installing update..." + (cd /usr/src/roundcubemail && bin/installto.sh -y $INSTALLDIR) + composer.phar update --no-dev fi if [ -f /run/secrets/roundcube_db_user ]; then @@ -89,8 +96,8 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then echo "include('$fn');" >> config/config.inc.php done - # initialize DB if not SQLite - echo "${ROUNDCUBEMAIL_DSNW}" | grep -q 'sqlite:' || bin/initdb.sh --dir=$PWD/SQL || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize databse. Please run $PWD/bin/initdb.sh manually." + # initialize or update DB + bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." else echo "WARNING: $PWD/config/config.inc.php already exists." echo "ROUNDCUBEMAIL_* environment variables have been ignored."