Add new ENV ROUNDCUBEMAIL_INSTALL_PLUGINS (#245)
authorWilliam Desportes <redacted>
Sun, 19 May 2024 20:23:14 +0000 (22:23 +0200)
committerGitHub <redacted>
Sun, 19 May 2024 20:23:14 +0000 (22:23 +0200)
* Added ROUNDCUBEMAIL_INSTALL_PLUGINS for installing plugins

* Re-work the composer install plugins to use the way document on the README

* Update the README

* Transform into a space to avoid crashes

* Fix displaying the plugin list

---------

Co-authored-by: Mikkel Bundgaard <redacted>
README.md
apache/docker-entrypoint.sh
fpm-alpine/docker-entrypoint.sh
fpm/docker-entrypoint.sh
templates/docker-entrypoint.sh

index 18f181827625bdd224ed2ed2b1ee5cb7978c1700..ec5a50c0641f72ed8e24b6ba79485fc538188f3c 100644 (file)
--- a/README.md
+++ b/README.md
@@ -38,6 +38,8 @@ 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_SKIN` - Configures the default theme. Defaults to `larry`
 
 `ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE` - File upload size limit; defaults to `5M`
@@ -123,16 +125,8 @@ For example, it may be used to increase the PHP memory limit (`memory_limit=128M
 
 ## Installing Roundcube Plugins
 
-With the latest updates, the Roundcube images contain the [Composer](https://getcomposer.org) binary
-which is used to install plugins. You can add and activate plugins by executing `composer require <package-name>` 
-inside a running Roundcube container:
-
-```sh
-docker exec -it roundcubemail composer require johndoh/contextmenu --update-no-dev
-```
-
-If you have mounted the container's volume `/var/www/html` the plugins installed persist on your host system.
-Otherwise they need to be (re-)installed every time you update or restart the Roundcube container.
+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.
 
 ## Examples
 
@@ -151,7 +145,7 @@ docker build -t roundcubemail .
 
 You can also create your own Docker image by extending from this image.
 
-For instance, you could extend this image to add composer and install requirements for builtin plugins or even external plugins:
+For instance, you could extend this image to add composer and install requirements for special plugins:
 
 ```Dockerfile
 FROM roundcube/roundcubemail:latest
@@ -164,15 +158,4 @@ RUN set -ex; \
     apt-get install -y --no-install-recommends \
         git \
     ; \
-    \
-    composer \
-      --working-dir=/usr/src/roundcubemail/ \
-      --prefer-dist \
-      --prefer-stable \
-      --update-no-dev \
-      --no-interaction \
-      --optimize-autoloader \
-      require \
-          johndoh/contextmenu \
-    ; \
 ```
index 0ffdc1ddf93337220fdac5eb8282394adcfe6a5d..4ea2ff21f9f403dd39338352b8abaecd295f287a 100755 (executable)
@@ -75,6 +75,25 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
 
+  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+    echo "Installing plugins from the list"
+    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+
+    # Change ',' into a space
+    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+
+    composer \
+      --working-dir=/usr/src/roundcubemail/ \
+      --prefer-dist \
+      --prefer-stable \
+      --update-no-dev \
+      --no-interaction \
+      --optimize-autoloader \
+      require \
+      -- \
+      ${ROUNDCUBEMAIL_PLUGINS_SH};
+  fi
+
   if [ ! -e config/config.inc.php ]; then
     GENERATED_DES_KEY=`head /dev/urandom | base64 | head -c 24`
     touch config/config.inc.php
index 0ffdc1ddf93337220fdac5eb8282394adcfe6a5d..4ea2ff21f9f403dd39338352b8abaecd295f287a 100755 (executable)
@@ -75,6 +75,25 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
 
+  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+    echo "Installing plugins from the list"
+    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+
+    # Change ',' into a space
+    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+
+    composer \
+      --working-dir=/usr/src/roundcubemail/ \
+      --prefer-dist \
+      --prefer-stable \
+      --update-no-dev \
+      --no-interaction \
+      --optimize-autoloader \
+      require \
+      -- \
+      ${ROUNDCUBEMAIL_PLUGINS_SH};
+  fi
+
   if [ ! -e config/config.inc.php ]; then
     GENERATED_DES_KEY=`head /dev/urandom | base64 | head -c 24`
     touch config/config.inc.php
index 0ffdc1ddf93337220fdac5eb8282394adcfe6a5d..4ea2ff21f9f403dd39338352b8abaecd295f287a 100755 (executable)
@@ -75,6 +75,25 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
 
+  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+    echo "Installing plugins from the list"
+    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+
+    # Change ',' into a space
+    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+
+    composer \
+      --working-dir=/usr/src/roundcubemail/ \
+      --prefer-dist \
+      --prefer-stable \
+      --update-no-dev \
+      --no-interaction \
+      --optimize-autoloader \
+      require \
+      -- \
+      ${ROUNDCUBEMAIL_PLUGINS_SH};
+  fi
+
   if [ ! -e config/config.inc.php ]; then
     GENERATED_DES_KEY=`head /dev/urandom | base64 | head -c 24`
     touch config/config.inc.php
index 0ffdc1ddf93337220fdac5eb8282394adcfe6a5d..4ea2ff21f9f403dd39338352b8abaecd295f287a 100644 (file)
@@ -75,6 +75,25 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
   : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
   : "${ROUNDCUBEMAIL_REQUEST_PATH:=/}"
 
+  if [ ! -z "${ROUNDCUBEMAIL_INSTALL_PLUGINS}" ]; then
+    echo "Installing plugins from the list"
+    echo "Plugins: ${ROUNDCUBEMAIL_PLUGINS}"
+
+    # Change ',' into a space
+    ROUNDCUBEMAIL_PLUGINS_SH=`echo "${ROUNDCUBEMAIL_PLUGINS}" | tr ',' ' '`
+
+    composer \
+      --working-dir=/usr/src/roundcubemail/ \
+      --prefer-dist \
+      --prefer-stable \
+      --update-no-dev \
+      --no-interaction \
+      --optimize-autoloader \
+      require \
+      -- \
+      ${ROUNDCUBEMAIL_PLUGINS_SH};
+  fi
+
   if [ ! -e config/config.inc.php ]; then
     GENERATED_DES_KEY=`head /dev/urandom | base64 | head -c 24`
     touch config/config.inc.php
git clone https://git.99rst.org/PROJECT