Fix composer plugins install (#250)
authorWilliam Desportes <redacted>
Sun, 4 Aug 2024 19:38:40 +0000 (21:38 +0200)
committerGitHub <redacted>
Sun, 4 Aug 2024 19:38:40 +0000 (21:38 +0200)
* Add new ENV ROUNDCUBEMAIL_COMPOSER_PLUGINS

* Fix composer plugin location and loading

* Remove ROUNDCUBEMAIL_INSTALL_PLUGINS

README.md
apache/docker-entrypoint.sh
examples/docker-compose-plugins.yaml [new file with mode: 0644]
fpm-alpine/docker-entrypoint.sh
fpm/docker-entrypoint.sh
templates/docker-entrypoint.sh

index e9e2f7d846530d0778fcc267e657b0b70fe13e18..54ba7932b380aed33f7607defba85c6a170d428e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ The following env variables can be set to configure your Roundcube Docker instan
 
 `ROUNDCUBEMAIL_PLUGINS` - List of built-in plugins to activate. Defaults to `archive,zipdownload`
 
-`ROUNDCUBEMAIL_INSTALL_PLUGINS` - Set to `1` or `true` to enable installation of plugins on startup
+`ROUNDCUBEMAIL_COMPOSER_PLUGINS` - The list of composer packages to install on startup. Use `ROUNDCUBEMAIL_PLUGINS` to enable them.
 
 `ROUNDCUBEMAIL_SKIN` - Configures the default theme. Defaults to `elastic`
 
@@ -83,17 +83,17 @@ The Roundcube containers do not store any data persistently by default. There ar
 some directories that could be mounted as volume or bind mount to share data between containers
 or to inject additional data into the container:
 
-* `/var/www/html`: Roundcube installation directory  
+* `/var/www/html`: Roundcube installation directory
   This is the document root of Roundcube. Plugins and additional skins are stored here amongst the Roundcube sources.
   Share this directory when using the FPM variant and let a webserver container serve the static files from here.
 
 * `/var/roundcube/config`: Location for additional config files
   See the [Advanced configuration](#advanced-configuration) section for details.
 
-* `/var/roundcube/db`: storage location of the SQLite database  
+* `/var/roundcube/db`: storage location of the SQLite database
   Only needed if using `ROUNDCUBEMAIL_DB_TYPE=sqlite` to persist the Roundcube database.
 
-* `/tmp/roundcube-temp`: Roundcube's temp folder  
+* `/tmp/roundcube-temp`: Roundcube's temp folder
   Temp files like uploaded attachments or thumbnail images are stored here.
   Share this directory via a volume when running multiple replicas of the roundcube container.
 
@@ -126,7 +126,15 @@ For example, it may be used to increase the PHP memory limit (`memory_limit=128M
 ## Installing Roundcube Plugins
 
 With the latest updates, the Roundcube image is now able to install plugins.
-You need to use `ROUNDCUBEMAIL_INSTALL_PLUGINS=1` in the env variables.
+You need to fill `ROUNDCUBEMAIL_COMPOSER_PLUGINS` with the list of composer packages to install.
+And set them in `ROUNDCUBEMAIL_PLUGINS` in order to enable the installed plugins.
+
+For example:
+
+```yaml
+  ROUNDCUBEMAIL_COMPOSER_PLUGINS: "weird-birds/thunderbird_labels,jfcherng-roundcube/show-folder-size,germancoding/tls_icon:^1.2"
+  ROUNDCUBEMAIL_PLUGINS: thunderbird_labels, show_folder_size, tls_icon
+```
 
 ## Examples
 
index 5aaba562a477f0887a866b95786e3fc5bb1c5397..587ca277f7806cd41c0766be30ada184af550398 100755 (executable)
@@ -4,6 +4,7 @@
 # PWD=`pwd`
 
 if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+  INSTALLDIR=`pwd`
   # docroot is empty
   if ! [ -e index.php -a -e bin/installto.sh ]; then
     echo >&2 "roundcubemail not found in $PWD - copying now..."
@@ -12,13 +13,19 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       ( set -x; ls -A; sleep 10 )
     fi
     tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf -
-    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD"
+    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR"
   # 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 update --no-dev
+    # Re-install composer modules (including plugins)
+    composer \
+          --working-dir=${INSTALLDIR} \
+          --prefer-dist \
+          --no-dev \
+          --no-interaction \
+          --optimize-autoloader \
+          install
   fi
 
   if [ -f /run/secrets/roundcube_db_user ]; then
@@ -74,16 +81,17 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
   : "${ROUNDCUBEMAIL_SKIN:=elastic}"
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
+  : "${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER:=$INSTALLDIR}"
 
-  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+  if [ ! -z "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" ]; then
     echo "Installing plugins from the list"
-    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+    echo "Plugins: ${ROUNDCUBEMAIL_COMPOSER_PLUGINS}"
 
     # Change ',' into a space
-    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+    ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" | tr ',' ' '`
 
     composer \
-      --working-dir=/usr/src/roundcubemail/ \
+      --working-dir=${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER} \
       --prefer-dist \
       --prefer-stable \
       --update-no-dev \
@@ -91,7 +99,7 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       --optimize-autoloader \
       require \
       -- \
-      ${ROUNDCUBEMAIL_PLUGINS_SH};
+      ${ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH};
   fi
 
   if [ ! -e config/config.inc.php ]; then
diff --git a/examples/docker-compose-plugins.yaml b/examples/docker-compose-plugins.yaml
new file mode 100644 (file)
index 0000000..ee21202
--- /dev/null
@@ -0,0 +1,25 @@
+version: '3'
+
+services:
+  roundcubemail:
+    image: roundcube/roundcubemail:latest
+    container_name: roundcubemail
+#    restart: unless-stopped
+    volumes:
+      - ./www:/var/www/html
+      - ./db/sqlite:/var/roundcube/db
+    ports:
+      - 9002:80
+    environment:
+      ROUNDCUBEMAIL_DB_TYPE: sqlite
+      ROUNDCUBEMAIL_SKIN: elastic
+      ROUNDCUBEMAIL_DEFAULT_HOST: tls://mail.example.org
+      ROUNDCUBEMAIL_SMTP_SERVER: tls://mail.example.org
+      ROUNDCUBEMAIL_COMPOSER_PLUGINS: "weird-birds/thunderbird_labels,jfcherng-roundcube/show-folder-size,germancoding/tls_icon:^1.2"
+      ROUNDCUBEMAIL_PLUGINS: thunderbird_labels, show_folder_size, tls_icon
+
+### Optional: add a full mail server stack to use with Roundcube like https://hub.docker.com/r/tvial/docker-mailserver
+#   mailserver:
+#     image: tvial/docker-mailserver:latest
+#     hostname: mail.example.org
+#     ...  # for more options see https://github.com/tomav/docker-mailserver#examples
index 5aaba562a477f0887a866b95786e3fc5bb1c5397..587ca277f7806cd41c0766be30ada184af550398 100755 (executable)
@@ -4,6 +4,7 @@
 # PWD=`pwd`
 
 if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+  INSTALLDIR=`pwd`
   # docroot is empty
   if ! [ -e index.php -a -e bin/installto.sh ]; then
     echo >&2 "roundcubemail not found in $PWD - copying now..."
@@ -12,13 +13,19 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       ( set -x; ls -A; sleep 10 )
     fi
     tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf -
-    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD"
+    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR"
   # 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 update --no-dev
+    # Re-install composer modules (including plugins)
+    composer \
+          --working-dir=${INSTALLDIR} \
+          --prefer-dist \
+          --no-dev \
+          --no-interaction \
+          --optimize-autoloader \
+          install
   fi
 
   if [ -f /run/secrets/roundcube_db_user ]; then
@@ -74,16 +81,17 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
   : "${ROUNDCUBEMAIL_SKIN:=elastic}"
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
+  : "${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER:=$INSTALLDIR}"
 
-  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+  if [ ! -z "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" ]; then
     echo "Installing plugins from the list"
-    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+    echo "Plugins: ${ROUNDCUBEMAIL_COMPOSER_PLUGINS}"
 
     # Change ',' into a space
-    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+    ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" | tr ',' ' '`
 
     composer \
-      --working-dir=/usr/src/roundcubemail/ \
+      --working-dir=${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER} \
       --prefer-dist \
       --prefer-stable \
       --update-no-dev \
@@ -91,7 +99,7 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       --optimize-autoloader \
       require \
       -- \
-      ${ROUNDCUBEMAIL_PLUGINS_SH};
+      ${ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH};
   fi
 
   if [ ! -e config/config.inc.php ]; then
index 5aaba562a477f0887a866b95786e3fc5bb1c5397..587ca277f7806cd41c0766be30ada184af550398 100755 (executable)
@@ -4,6 +4,7 @@
 # PWD=`pwd`
 
 if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+  INSTALLDIR=`pwd`
   # docroot is empty
   if ! [ -e index.php -a -e bin/installto.sh ]; then
     echo >&2 "roundcubemail not found in $PWD - copying now..."
@@ -12,13 +13,19 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       ( set -x; ls -A; sleep 10 )
     fi
     tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf -
-    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD"
+    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR"
   # 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 update --no-dev
+    # Re-install composer modules (including plugins)
+    composer \
+          --working-dir=${INSTALLDIR} \
+          --prefer-dist \
+          --no-dev \
+          --no-interaction \
+          --optimize-autoloader \
+          install
   fi
 
   if [ -f /run/secrets/roundcube_db_user ]; then
@@ -74,16 +81,17 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
   : "${ROUNDCUBEMAIL_SKIN:=elastic}"
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
+  : "${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER:=$INSTALLDIR}"
 
-  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+  if [ ! -z "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" ]; then
     echo "Installing plugins from the list"
-    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+    echo "Plugins: ${ROUNDCUBEMAIL_COMPOSER_PLUGINS}"
 
     # Change ',' into a space
-    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+    ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" | tr ',' ' '`
 
     composer \
-      --working-dir=/usr/src/roundcubemail/ \
+      --working-dir=${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER} \
       --prefer-dist \
       --prefer-stable \
       --update-no-dev \
@@ -91,7 +99,7 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       --optimize-autoloader \
       require \
       -- \
-      ${ROUNDCUBEMAIL_PLUGINS_SH};
+      ${ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH};
   fi
 
   if [ ! -e config/config.inc.php ]; then
index 5aaba562a477f0887a866b95786e3fc5bb1c5397..587ca277f7806cd41c0766be30ada184af550398 100644 (file)
@@ -4,6 +4,7 @@
 # PWD=`pwd`
 
 if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+  INSTALLDIR=`pwd`
   # docroot is empty
   if ! [ -e index.php -a -e bin/installto.sh ]; then
     echo >&2 "roundcubemail not found in $PWD - copying now..."
@@ -12,13 +13,19 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       ( set -x; ls -A; sleep 10 )
     fi
     tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf -
-    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD"
+    echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $INSTALLDIR"
   # 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 update --no-dev
+    # Re-install composer modules (including plugins)
+    composer \
+          --working-dir=${INSTALLDIR} \
+          --prefer-dist \
+          --no-dev \
+          --no-interaction \
+          --optimize-autoloader \
+          install
   fi
 
   if [ -f /run/secrets/roundcube_db_user ]; then
@@ -74,16 +81,17 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
   : "${ROUNDCUBEMAIL_SKIN:=elastic}"
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
+  : "${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER:=$INSTALLDIR}"
 
-  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+  if [ ! -z "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" ]; then
     echo "Installing plugins from the list"
-    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+    echo "Plugins: ${ROUNDCUBEMAIL_COMPOSER_PLUGINS}"
 
     # Change ',' into a space
-    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+    ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_COMPOSER_PLUGINS}" | tr ',' ' '`
 
     composer \
-      --working-dir=/usr/src/roundcubemail/ \
+      --working-dir=${ROUNDCUBEMAIL_COMPOSER_PLUGINS_FOLDER} \
       --prefer-dist \
       --prefer-stable \
       --update-no-dev \
@@ -91,7 +99,7 @@ if  [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
       --optimize-autoloader \
       require \
       -- \
-      ${ROUNDCUBEMAIL_PLUGINS_SH};
+      ${ROUNDCUBEMAIL_COMPOSER_PLUGINS_SH};
   fi
 
   if [ ! -e config/config.inc.php ]; then
git clone https://git.99rst.org/PROJECT