From: William Desportes Date: Sun, 4 Aug 2024 19:38:40 +0000 (+0200) Subject: Fix composer plugins install (#250) X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=5c73c3e40aadf966374a795b2a650519f548476d;p=roundcube-roundcubemail-docker.git Fix composer plugins install (#250) * Add new ENV ROUNDCUBEMAIL_COMPOSER_PLUGINS * Fix composer plugin location and loading * Remove ROUNDCUBEMAIL_INSTALL_PLUGINS --- diff --git a/README.md b/README.md index e9e2f7d..54ba793 100644 --- 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 diff --git a/apache/docker-entrypoint.sh b/apache/docker-entrypoint.sh index 5aaba56..587ca27 100755 --- a/apache/docker-entrypoint.sh +++ b/apache/docker-entrypoint.sh @@ -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 index 0000000..ee21202 --- /dev/null +++ b/examples/docker-compose-plugins.yaml @@ -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 diff --git a/fpm-alpine/docker-entrypoint.sh b/fpm-alpine/docker-entrypoint.sh index 5aaba56..587ca27 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 || "$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/fpm/docker-entrypoint.sh b/fpm/docker-entrypoint.sh index 5aaba56..587ca27 100755 --- a/fpm/docker-entrypoint.sh +++ b/fpm/docker-entrypoint.sh @@ -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/templates/docker-entrypoint.sh b/templates/docker-entrypoint.sh index 5aaba56..587ca27 100644 --- a/templates/docker-entrypoint.sh +++ b/templates/docker-entrypoint.sh @@ -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