# Set these here so the values are visible in the logs for debugging.
export ROUNDCUBEMAIL_TEST_IMAGE="${{ matrix.docker-tag }}"
export HTTP_PORT="${{ matrix.http-port || '80' }}"
+ export SKIP_POST_SETUP_SCRIPT_TEST="yes"
for testFile in ${{ join(matrix.test-files, ' ') }};
do
docker compose -f ./tests/docker-compose.test-${testFile}.yml \
ROUNDCUBEMAIL_PLUGINS: thunderbird_labels, show_folder_size, tls_icon
```
+To overwrite the default config of a plugin you might need to use a post-setup script (see below) that moves a custom config file into the plugin's directory.
+
+## Pre-setup and post-setup tasks
+
+In order to execute custom tasks before or after Roundcubemail is set up in the container, you can bind-mount directories to `/entrypoint-tasks/pre-setup/` and `/entrypoint-tasks/post-setup/`. Then all executable files in those directories are executed at the beginning or the end of the actual entrypoint-script, respectively. If an executable exits with a code > 1, the entrypoint script exits, too.
+
+Each executable receives the container's `CMD` as arguments.
+
+They are executed in alphabetical order (the way `bash` understands it in `en_US` locale).
+
+If the Roundcubemail-setup is skipped due to a custom `CMD`, these tasks are skipped as well.
+
+
## HTTPS
Currently all images are configured to speak HTTP. To provide HTTPS please run an additional reverse proxy in front of them, which handles certificates and terminates TLS. Alternatively you could derive from our images (or use the advanced configuration methods) to make Apache or nginx provide HTTPS – but please refrain from opening issues asking for support with such a setup.
# PWD=`pwd`
+run_entrypoint_tasks() {
+ phase="$1"
+ shift
+ shopt -s nullglob
+ echo "Running $phase-setup tasks:"
+ for file in /entrypoint-tasks/"$phase-setup"/*; do
+ if test ! -f "$file"; then
+ echo "Ignoring $file because it is not a regular file."
+ continue;
+ fi
+ if test ! -x "$file"; then
+ echo "Ignoring $file because it is not executable."
+ continue;
+ fi
+ echo "Running $phase-setup task $file:"
+ "$file" "$@"
+ # Exit in case of an error in an executable.
+ exit_code=$?
+ if test $exit_code -ne 0; then
+ echo "The task exited with code $exit_code, thus the entrypoint script is exiting, too!"
+ exit $exit_code
+ fi
+ echo 'Done.'
+ done
+ shopt -u nullglob
+}
+
if [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+ run_entrypoint_tasks pre "$@"
+
INSTALLDIR=`pwd`
# docroot is empty
if ! [ -e index.php -a -e bin/installto.sh ]; then
which apk && apk add --no-cache $ASPELL_PACKAGES
fi
+ run_entrypoint_tasks post "$@"
fi
exec "$@"
# PWD=`pwd`
+run_entrypoint_tasks() {
+ phase="$1"
+ shift
+ shopt -s nullglob
+ echo "Running $phase-setup tasks:"
+ for file in /entrypoint-tasks/"$phase-setup"/*; do
+ if test ! -f "$file"; then
+ echo "Ignoring $file because it is not a regular file."
+ continue;
+ fi
+ if test ! -x "$file"; then
+ echo "Ignoring $file because it is not executable."
+ continue;
+ fi
+ echo "Running $phase-setup task $file:"
+ "$file" "$@"
+ # Exit in case of an error in an executable.
+ exit_code=$?
+ if test $exit_code -ne 0; then
+ echo "The task exited with code $exit_code, thus the entrypoint script is exiting, too!"
+ exit $exit_code
+ fi
+ echo 'Done.'
+ done
+ shopt -u nullglob
+}
+
if [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+ run_entrypoint_tasks pre "$@"
+
INSTALLDIR=`pwd`
# docroot is empty
if ! [ -e index.php -a -e bin/installto.sh ]; then
which apk && apk add --no-cache $ASPELL_PACKAGES
fi
+ run_entrypoint_tasks post "$@"
fi
exec "$@"
# PWD=`pwd`
+run_entrypoint_tasks() {
+ phase="$1"
+ shift
+ shopt -s nullglob
+ echo "Running $phase-setup tasks:"
+ for file in /entrypoint-tasks/"$phase-setup"/*; do
+ if test ! -f "$file"; then
+ echo "Ignoring $file because it is not a regular file."
+ continue;
+ fi
+ if test ! -x "$file"; then
+ echo "Ignoring $file because it is not executable."
+ continue;
+ fi
+ echo "Running $phase-setup task $file:"
+ "$file" "$@"
+ # Exit in case of an error in an executable.
+ exit_code=$?
+ if test $exit_code -ne 0; then
+ echo "The task exited with code $exit_code, thus the entrypoint script is exiting, too!"
+ exit $exit_code
+ fi
+ echo 'Done.'
+ done
+ shopt -u nullglob
+}
+
if [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+ run_entrypoint_tasks pre "$@"
+
INSTALLDIR=`pwd`
# docroot is empty
if ! [ -e index.php -a -e bin/installto.sh ]; then
which apk && apk add --no-cache $ASPELL_PACKAGES
fi
+ run_entrypoint_tasks post "$@"
fi
exec "$@"
# PWD=`pwd`
+run_entrypoint_tasks() {
+ phase="$1"
+ shift
+ shopt -s nullglob
+ echo "Running $phase-setup tasks:"
+ for file in /entrypoint-tasks/"$phase-setup"/*; do
+ if test ! -f "$file"; then
+ echo "Ignoring $file because it is not a regular file."
+ continue;
+ fi
+ if test ! -x "$file"; then
+ echo "Ignoring $file because it is not executable."
+ continue;
+ fi
+ echo "Running $phase-setup task $file:"
+ "$file" "$@"
+ # Exit in case of an error in an executable.
+ exit_code=$?
+ if test $exit_code -ne 0; then
+ echo "The task exited with code $exit_code, thus the entrypoint script is exiting, too!"
+ exit $exit_code
+ fi
+ echo 'Done.'
+ done
+ shopt -u nullglob
+}
+
if [[ "$1" == apache2* || "$1" == php-fpm || "$1" == bin* ]]; then
+ run_entrypoint_tasks pre "$@"
+
INSTALLDIR=`pwd`
# docroot is empty
if ! [ -e index.php -a -e bin/installto.sh ]; then
which apk && apk add --no-cache $ASPELL_PACKAGES
fi
+ run_entrypoint_tasks post "$@"
fi
exec "$@"
- ROUNDCUBEMAIL_DB_USER=roundcube # same as pgsql POSTGRES_USER env name
- ROUNDCUBEMAIL_DB_PASSWORD=roundcube # same as pgsql POSTGRES_PASSWORD env name
- ROUNDCUBEMAIL_SKIN=larry # Install non-default skin
+ volumes:
+ - "./pre-setup/:/entrypoint-tasks/pre-setup/"
+ - "./post-setup/:/entrypoint-tasks/post-setup/"
roundcubedb:
image: postgres:alpine
command: /tests/run.sh
environment:
- ROUNDCUBE_URL=http://roundcubemail:${HTTP_PORT:-80}/
+ - SKIP_POST_SETUP_SCRIPT_TEST=${SKIP_POST_SETUP_SCRIPT_TEST:-no}
volumes:
- ./run.sh:/tests/run.sh:ro
working_dir: /tests
- roundcubemail-fpm
volumes:
- www-vol:/var/www/html
+ - "./pre-setup/:/entrypoint-tasks/pre-setup/"
+ - "./post-setup/:/entrypoint-tasks/post-setup/"
environment:
- ROUNDCUBEMAIL_DB_TYPE=pgsql
- ROUNDCUBEMAIL_DB_HOST=roundcubedb # same as pgsql container name
working_dir: /tests
environment:
ROUNDCUBE_URL: http://roundcubenginx/
+ SKIP_POST_SETUP_SCRIPT_TEST: ${SKIP_POST_SETUP_SCRIPT_TEST:-no}
networks:
roundcube_test_net:
--- /dev/null
+#!/usr/bin/env bash
+
+set -e
+
+# Check that the file, which a pre-setup-script should have created, is present.
+test -f /tmp/something
+
+# Leave a marker that can be checked from the outside.
+echo yes > public_html/post_setup_script.txt
--- /dev/null
+#!/usr/bin/env bash
+
+set -e
+
+touch /tmp/something
+touch /tmp/anotherfile
--- /dev/null
+#!/usr/bin/env bash
+
+set -e
+
+# This script should not be run by the entrypoint-script!
+#
+# Create a regular file, so we can check that it doesn't exist in a later running script.
+touch /tmp/shouldnotexist
--- /dev/null
+#!/usr/bin/env bash
+
+set -e
+
+# Remove a file we previously created in "a-script.sh". If this fails, there's a problem in the order of script
+# execution.
+rm /tmp/anotherfile
+
+if test -f /tmp/shouldnotexist; then
+ echo "Error: File /tmp/shouldnotexist should not exist but does!"
+ exit 1
+fi
findText 'Warning: This webmail service requires Javascript!' "${HOMEPAGE_TEXT}"
echo 'Homepage is okay'
-echo 'End.'
\ No newline at end of file
+if test "$SKIP_POST_SETUP_SCRIPT_TEST" != "yes"; then
+ echo 'Checking post-setup-script marker'
+ POST_SETUP_SCRIPT_TEXT=$(curl -s --fail "${ROUNDCUBE_URL}post_setup_script.txt")
+ findText 'yes' "${POST_SETUP_SCRIPT_TEXT}"
+ echo 'post-setup-script marker is ok'
+fi
+
+echo 'End.'