From 4919043b73e161b0ddad40e55ac75461e1f0b569 Mon Sep 17 00:00:00 2001 From: J0WI Date: Sat, 25 Nov 2017 02:09:08 +0100 Subject: [PATCH 1/2] Add support for linked PostgreSQL container --- docker/docker-entrypoint.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 8b57b618b..485f05ccf 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -15,9 +15,16 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD" fi - if [ ! -z "${!MYSQL_ENV_MYSQL_*}" ]; then + if [ ! -z "${!POSTGRES_ENV_POSTGRES_*}" ]; then + : "${ROUNDCUBEMAIL_DB_TYPE:=pgsql}" + : "${ROUNDCUBEMAIL_DB_HOST:=postgres}" + : "${ROUNDCUBEMAIL_DB_USER:=${POSTGRES_ENV_POSTGRES_USER}}" + : "${ROUNDCUBEMAIL_DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD}}" + : "${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}}" + elif [ ! -z "${!MYSQL_ENV_MYSQL_*}" ]; then : "${ROUNDCUBEMAIL_DB_TYPE:=mysql}" - : "${ROUNDCUBEMAIL_DB_HOST:=${MYSQL_ENV_MYSQL_HOST:-mysql}}" + : "${ROUNDCUBEMAIL_DB_HOST:=mysql}" : "${ROUNDCUBEMAIL_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}" if [ "$ROUNDCUBEMAIL_DB_USER" = 'root' ]; then : "${ROUNDCUBEMAIL_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD}}" @@ -28,8 +35,10 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then : "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}://${ROUNDCUBEMAIL_DB_USER}:${ROUNDCUBEMAIL_DB_PASSWORD}@${ROUNDCUBEMAIL_DB_HOST}/${ROUNDCUBEMAIL_DB_NAME}}" else # use local SQLite DB in /var/www/html/db + : "${ROUNDCUBEMAIL_DB_TYPE:=sqlite}" : "${ROUNDCUBEMAIL_DB_DIR:=$PWD/db}" - : "${ROUNDCUBEMAIL_DSNW:=sqlite:///$ROUNDCUBEMAIL_DB_DIR/sqlite.db?mode=0646}" + : "${ROUNDCUBEMAIL_DB_NAME:=sqlite}" + : "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}:///$ROUNDCUBEMAIL_DB_DIR/${ROUNDCUBEMAIL_DB_NAME}.db?mode=0646}" mkdir -p $ROUNDCUBEMAIL_DB_DIR chown www-data:www-data $ROUNDCUBEMAIL_DB_DIR @@ -70,4 +79,4 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi fi -exec "$@" \ No newline at end of file +exec "$@" From 5a315c47d9908a80352dc952d3472af3302e9f95 Mon Sep 17 00:00:00 2001 From: J0WI Date: Sat, 25 Nov 2017 02:09:58 +0100 Subject: [PATCH 2/2] Add documenation for more database providers --- docker/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docker/README.md b/docker/README.md index 22b58970e..af939b336 100644 --- a/docker/README.md +++ b/docker/README.md @@ -28,14 +28,15 @@ this option should not be used for production. The recommended way to run Roundcube is connected to a MySQL database. Specify the following env variables to do so: -`MYSQL_ENV_MYSQL_HOST` - Host (or Docker instance) name of the MySQL service; defaults to `mysql` +`ROUNDCUBEMAIL_DB_TYPE` - Database provider; currently supported: `mysql`, `pgsql`, `sqlite` -`MYSQL_ENV_MYSQL_USER` - The database username for Roundcube; defaults to `root` +`ROUNDCUBEMAIL_DB_HOST` - Host (or Docker instance) name of the database service; defaults to `mysql` or `postgres` depending on linked containers. -`MYSQL_ENV_MYSQL_PASSWORD` - The password for the database connection or -`MYSQL_ENV_MYSQL_ROOT_PASSWORD` - if the database username is `root` +`ROUNDCUBEMAIL_DB_USER` - The database username for Roundcube; defaults to `root` on `mysql` -`MYSQL_ENV_MYSQL_DATABASE` - The database name for Roundcube to use; defaults to `roundcubemail` +`ROUNDCUBEMAIL_DB_PASSWORD` - The password for the database connection + +`ROUNDCUBEMAIL_DB_NAME` - The database name for Roundcube to use; defaults to `roundcubemail` Before staring the container, please make sure that the supplied database exists and the given database user has privileges to create tables. @@ -43,7 +44,7 @@ to create tables. Run it with a link to the MySQL host and the username/password variables: ``` -docker run -e MYSQL_ENV_MYSQL_ROOT_PASSWORD=my-secret-password --link=mysql:mysql -d roundcube/roundcubemail +docker run --link=mysql:mysql -d roundcube/roundcubemail ``` ## Building a Docker Container