Extend Dockerfile with volumes for shared temp data and custon config files

pull/6085/head
Thomas Bruederli 7 years ago
parent 8e2f6275a4
commit 400066c2eb

@ -19,7 +19,10 @@ RUN docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu && docker-p
# enable mod_rewrite # enable mod_rewrite
RUN a2enmod rewrite RUN a2enmod rewrite
# expose these volumes
VOLUME /var/www/html VOLUME /var/www/html
VOLUME /var/roundcube/config
VOLUME /tmp/roundcube-temp
# Define Roundcubemail version # Define Roundcubemail version
ENV ROUNDCUBEMAIL_VERSION 1.3.3 ENV ROUNDCUBEMAIL_VERSION 1.3.3
@ -37,6 +40,9 @@ RUN curl -o roundcubemail.tar.gz -SL https://github.com/roundcube/roundcubemail/
&& rm -rf /usr/src/roundcubemail/installer \ && rm -rf /usr/src/roundcubemail/installer \
&& rm roundcubemail.tar.gz && rm roundcubemail.tar.gz
# include the wait-for-it.sh script
RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh > /wait-for-it.sh && chmod +x /wait-for-it.sh
COPY docker-entrypoint.sh / COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"] ENTRYPOINT ["/docker-entrypoint.sh"]

@ -47,6 +47,19 @@ Run it with a link to the MySQL host and the username/password variables:
docker run --link=mysql:mysql -d roundcube/roundcubemail docker run --link=mysql:mysql -d roundcube/roundcubemail
``` ```
### Advanced configuration
Apart from the above described environment variables, the Docker image also allows to add custom config files
which are merged into Roundcube's default config. Therefore the image defines a volume `/var/roundcube/config`
where additional config files (`*.php`) are searched and included. Mount a local directory with your config
files - check for valid PHP syntax - when starting the Docker container:
```
docker run -v ./config/:/var/roundcube/config/ -d roundcube/roundcubemail
```
Check our wiki for a reference of [Roundcube config options](https://github.com/roundcube/roundcubemail/wiki/Configuration).
## Building a Docker image ## Building a Docker image
Use the `Dockerfile` in this directory to build your own Docker image. Use the `Dockerfile` in this directory to build your own Docker image.

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
set -ex # set -ex
# PWD=`pwd` # PWD=`pwd`
@ -22,6 +22,8 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
: "${ROUNDCUBEMAIL_DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD}}" : "${ROUNDCUBEMAIL_DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD}}"
: "${ROUNDCUBEMAIL_DB_NAME:=${POSTGRES_ENV_POSTGRES_DB:-roundcubemail}}" : "${ROUNDCUBEMAIL_DB_NAME:=${POSTGRES_ENV_POSTGRES_DB:-roundcubemail}}"
: "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}://${ROUNDCUBEMAIL_DB_USER}:${ROUNDCUBEMAIL_DB_PASSWORD}@${ROUNDCUBEMAIL_DB_HOST}/${ROUNDCUBEMAIL_DB_NAME}}" : "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}://${ROUNDCUBEMAIL_DB_USER}:${ROUNDCUBEMAIL_DB_PASSWORD}@${ROUNDCUBEMAIL_DB_HOST}/${ROUNDCUBEMAIL_DB_NAME}}"
/wait-for-it.sh ${ROUNDCUBEMAIL_DB_HOST}:5432 -t 30
elif [ ! -z "${!MYSQL_ENV_MYSQL_*}" ]; then elif [ ! -z "${!MYSQL_ENV_MYSQL_*}" ]; then
: "${ROUNDCUBEMAIL_DB_TYPE:=mysql}" : "${ROUNDCUBEMAIL_DB_TYPE:=mysql}"
: "${ROUNDCUBEMAIL_DB_HOST:=mysql}" : "${ROUNDCUBEMAIL_DB_HOST:=mysql}"
@ -33,6 +35,8 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
fi fi
: "${ROUNDCUBEMAIL_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-roundcubemail}}" : "${ROUNDCUBEMAIL_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:-roundcubemail}}"
: "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}://${ROUNDCUBEMAIL_DB_USER}:${ROUNDCUBEMAIL_DB_PASSWORD}@${ROUNDCUBEMAIL_DB_HOST}/${ROUNDCUBEMAIL_DB_NAME}}" : "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}://${ROUNDCUBEMAIL_DB_USER}:${ROUNDCUBEMAIL_DB_PASSWORD}@${ROUNDCUBEMAIL_DB_HOST}/${ROUNDCUBEMAIL_DB_NAME}}"
/wait-for-it.sh ${ROUNDCUBEMAIL_DB_HOST}:3306 -t 30
else else
# use local SQLite DB in /var/www/html/db # use local SQLite DB in /var/www/html/db
: "${ROUNDCUBEMAIL_DB_TYPE:=sqlite}" : "${ROUNDCUBEMAIL_DB_TYPE:=sqlite}"
@ -69,10 +73,14 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
\$config['log_dir'] = '${ROUNDCUBEMAIL_LOG_DIR}'; \$config['log_dir'] = '${ROUNDCUBEMAIL_LOG_DIR}';
\$config['temp_dir'] = '${ROUNDCUBEMAIL_TEMP_DIR}'; \$config['temp_dir'] = '${ROUNDCUBEMAIL_TEMP_DIR}';
\$config['plugins'] = ['${ROUNDCUBEMAIL_PLUGINS_PHP}']; \$config['plugins'] = ['${ROUNDCUBEMAIL_PLUGINS_PHP}'];
?>" | tee config/config.inc.php " | tee config/config.inc.php
for fn in `ls /var/roundcube/config/*.php`; do
echo "include('$fn');" >> config/config.inc.php
done
# initialize DB if not SQLite # initialize DB if not SQLite
echo "${ROUNDCUBEMAIL_DSNW}" | grep -q 'sqlite:' || bin/initdb.sh --dir=$PWD/SQL || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube echo "${ROUNDCUBEMAIL_DSNW}" | grep -q 'sqlite:' || bin/initdb.sh --dir=$PWD/SQL || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize databse. Please run $PWD/bin/initdb.sh manually."
else else
echo "WARNING: $PWD/config/config.inc.php already exists." echo "WARNING: $PWD/config/config.inc.php already exists."
echo "ROUNDCUBEMAIL_* environment variables have been ignored." echo "ROUNDCUBEMAIL_* environment variables have been ignored."

Loading…
Cancel
Save