roundcube / roundcubemail-docker

Resources to build Docker images for Roundcube Webmail
277 stars 125 forks source link

Error loading config of additionally installed plugins #220

Open chbusold opened 1 year ago

chbusold commented 1 year ago

I created a Docker image derived from this to install another plugin using composer and install a custom configuration file like this:

COPY --chown=root:root --chmod=644 authres_status/config.inc.php /var/www/html/plugins/authres_status/config.inc.php

In the logs I see a lot of errors about not being able to load the file:

errors: <de821df1> PHP Error: Failed to load config from /var/www/html/plugins/authres_status/config.inc.php in /var/www/html/program/lib/Roundcube/rcube_plugin.php on line 166 (POST /?_task=settings&_action=refresh)

I checked inside the container to confirm the file exists and is readable for www-data:

root@c71f5f951f56:/var/www/html# ls -al /var/www/html/plugins/authres_status
total 92
drwxr-xr-x  1 root root  4096 May 24 19:52 .
drwxr-xr-x  1 root root  4096 May 24 19:52 ..
-rw-r--r--  1 root root    47 Jan 26 20:07 .gitignore
drwxr-xr-x  2 root root  4096 Jan 26 20:07 .tx
-rwxr-xr-x  1 root root   697 Jan 26 20:07 LICENSE
-rwxr-xr-x  1 root root  2842 Jan 26 20:07 README.md
-rwxr-xr-x  1 root root   952 Jan 26 20:07 authres_status.js
-rwxr-xr-x  1 root root 22753 Jan 26 20:07 authres_status.php
-rwxr-xr-x  1 root root  1444 Jan 26 20:07 composer.json
-rw-r--r--  1 root root  1505 May 24 19:52 config.inc.php
-rw-r--r--  1 root root  1505 Jan 26 20:07 config.inc.php.dist
drwxr-xr-x  2 root root  4096 Jan 26 20:07 images
drwxr-xr-x  2 root root  4096 Jan 26 20:07 localization
-rw-r--r--  1 root root   217 Jan 26 20:07 phpcs.xml
-rw-r--r--  1 root root   689 Jan 26 20:07 phpunit.xml
drwxr-xr-x 15 root root  4096 Jan 26 20:07 skins
drwxr-xr-x  2 root root  4096 Jan 26 20:07 tests

Am I missing something obvious?

chbusold commented 1 year ago

After I while I found the root cause. When I do install the plugin using composer like this

composer \
      --working-dir=/usr/src/roundcubemail/ \
      --prefer-dist \
      --prefer-stable \
      --update-no-dev \
      --no-interaction \
      --optimize-autoloader \
      require \
          pimlie/authres_status:* \
    ; \

it creates an empty default config in /usr/src/roundcubemail/plugins/authres_status/config.inc.php, which then overwrites my config when all the stuff is copied into /var/www/html in docker-entrypoint.sh. A workaround is to remove this file after running composer. However, in general the image seems to be confused at preexisting plugin config files in /var/www/html, causing the 10s startup delay. A better solution may be to provide a way to inject plugin configs during docker-entrypoint.sh. Or should plugin configs be provided in /var/roundcube/config?

thomascube commented 1 year ago

There's a convention that plugin configs are searched in Roundcube's config folder named the same as the plugin (e.g. authres_status.inc.php). If you want to include the config right in your Docker image, COPY the file into /usr/src/roundcubemail/config and it should be copied into the right location when the container starts.

The /var/roundcube/config volume is meant to hold configs that are injected into the container and need to be configured for each deployment.

Stef-33560 commented 8 months ago

Hi

A little thing I dont yet understand in the README:

Using working-dir=/usr/src/roundcubemail put plugins un vendor, example with kolab/calendar, wich is not found after a brand new startup of an image 🤔

FROM roundcube/roundcubemail:latest-fpm-alpine

RUN set -ex; \
    yes | composer \
        --working-dir=/usr/src/roundcubemail/ \
        --prefer-dist \
        --prefer-stable \
        --update-no-dev \
        --no-interaction \
        --optimize-autoloader \
        require \
            guzzlehttp/guzzle \
            johndoh/globaladdressbook \
            kolab/calendar \
            kolab/tasklist \
            syncgw/roundcube_plugin \
    ;

COPY ["/plugins/calendar/config.inc.php", "/usr/src/roundcubemail/config/calendar/config.inc.php"]

COPY ["/plugins/tasklist/config.inc.php", "/usr/src/roundcubemail/config/tasklist/config.inc.php"]

COPY ["/plugins/libkolab/libokolab.min.css", "/usr/src/roundcubemail/config/libkolab/skins/elastic/libokolab.min.css"]`
Capture d’écran 2023-12-27 à 18 32 39

With the default roundcube/roundcubemail image, using inside a composer require put theme in plugins folder... And then works.

Thanks a lot for any explanation 🙂