Automatic updates on mounted/shared volume `/var/www/html`
authorThomas Bruederli <redacted>
Sun, 4 Oct 2020 20:31:36 +0000 (22:31 +0200)
committerThomas Bruederli <redacted>
Mon, 5 Oct 2020 20:53:27 +0000 (22:53 +0200)
- 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

apache/Dockerfile
apache/docker-entrypoint.sh
fpm-alpine/Dockerfile
fpm-alpine/docker-entrypoint.sh
fpm/Dockerfile
fpm/docker-entrypoint.sh

index e1f2423e2eaf252ff2f2d34f5f369baa0c1c9a9a..ce2047364f7923c5de4a6b060d98df795e7b408b 100644 (file)
@@ -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
 
index 7757d1ea09775597072476acfb9e767f79384d42..68df92c468a92b472a22cfecb45fd6fcee634118 100755 (executable)
@@ -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."
index 7096de780553eb7bd2e07f3a1ad2e8001eb57944..85379182a69bca8c5a26110be73e697cf44797ef 100644 (file)
@@ -1,12 +1,13 @@
 FROM php:7.3-fpm-alpine
 LABEL maintainer="Thomas Bruederli <thomas@roundcube.net>"
 
-# 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
index 733453eaf549f5c52b4be0603604f5115de8269b..78804ffb4125dd5001d881da1319d4102498ea0f 100755 (executable)
@@ -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."
index 6b4088911a8dfa9ab10ff1ce9448717a85dcc0d3..bcb3a9ae4696469ae935ed74ec9c926ed7eb993a 100644 (file)
@@ -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
index 7757d1ea09775597072476acfb9e767f79384d42..68df92c468a92b472a22cfecb45fd6fcee634118 100755 (executable)
@@ -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."
git clone https://git.99rst.org/PROJECT