Refactored Dockerfile as suggested in #5874
It's now based on a php:7.1-apache image and pre-configures Roundcube from the given environment variables to either connect to a MySQL server or to use a local SQLite database. Added a README file with some basic information and description of the most important denv variables. More configuration options are yet to come. This is a pre-requisite for #5827.pull/6043/head
parent
9fc1c0bce0
commit
4b4c4633bc
@ -1,36 +0,0 @@
|
||||
FROM debian:jessie
|
||||
MAINTAINER Alex Brandt <alunduil@alunduil.com>
|
||||
|
||||
EXPOSE 80 443
|
||||
|
||||
RUN apt-get -qq update
|
||||
RUN apt-get install -qq apache2-mpm-event ca-certificates
|
||||
|
||||
RUN apt-get install -qq php5 php-pear php5-mysql php5-pgsql php5-sqlite
|
||||
RUN pear install mail_mime net_smtp net_idna2-beta auth_sasl net_sieve crypt_gpg
|
||||
|
||||
RUN a2enmod expires
|
||||
RUN a2enmod headers
|
||||
RUN a2enmod ssl
|
||||
|
||||
RUN sed -e 's|/var/www/html|/var/www/public_html|' -e 's@\(Log \+\)[^ ]\+@\1"|/bin/cat"@' -i /etc/apache2/sites-available/000-default.conf
|
||||
RUN sed -e 's|</VirtualHost>|\t<Directory /var/www/public_html/>\n\t\tAllowOverride All\n\t</Directory>\n&|' -i /etc/apache2/sites-available/000-default.conf
|
||||
RUN a2ensite 000-default
|
||||
|
||||
RUN sed -e 's|/var/www/html|/var/www/public_html|' -e 's@\(Log \+\)[^ ]\+@\1"|/bin/cat"@' -i /etc/apache2/sites-available/default-ssl.conf
|
||||
RUN sed -e 's|</VirtualHost>|\t<Directory /var/www/public_html/>\n\t\tAllowOverride All\n\t</Directory>\n&|' -i /etc/apache2/sites-available/default-ssl.conf
|
||||
RUN sed -e '/SSLCertificateKeyFile/s|ssl-cert-snakeoil.key|ssl-cert.key|' -e '/SSLCertificateFile/s|ssl-cert-snakeoil.pem|ssl-cert.pem|' -i /etc/apache2/sites-available/default-ssl.conf
|
||||
RUN ln -snf ssl-cert-snakeoil.pem /etc/ssl/certs/ssl-cert.pem
|
||||
RUN ln -snf ssl-cert-snakeoil.key /etc/ssl/private/ssl-cert.key
|
||||
RUN a2ensite default-ssl
|
||||
|
||||
RUN rm -rf /var/www
|
||||
ADD . /var/www
|
||||
|
||||
RUN echo '<?php\n$config = array();' > /var/www/config/config.inc.php
|
||||
RUN rm -rf /var/www/installer
|
||||
|
||||
RUN . /etc/apache2/envvars && chown -R ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /var/www/temp /var/www/logs
|
||||
|
||||
ENTRYPOINT [ "/usr/sbin/apache2ctl", "-D", "FOREGROUND" ]
|
||||
CMD [ "-k", "start" ]
|
@ -0,0 +1,42 @@
|
||||
FROM php:7.1-apache
|
||||
MAINTAINER Thomas Bruederli <thomas@roundcube.net>
|
||||
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get install -qq \
|
||||
libpq-dev \
|
||||
libsqlite3-dev \
|
||||
libicu-dev \
|
||||
zlib1g-dev \
|
||||
libpng-dev \
|
||||
libfreetype6-dev \
|
||||
libjpeg62-turbo-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN docker-php-ext-install -j$(nproc) intl exif pdo pdo_mysql pdo_sqlite pdo_pgsql zip
|
||||
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) gd
|
||||
|
||||
# enable mod_rewrite
|
||||
RUN a2enmod rewrite
|
||||
|
||||
VOLUME /var/www/html
|
||||
|
||||
# Define Roundcubemail version
|
||||
ENV ROUNDCUBEMAIL_VERSION 1.3.2
|
||||
|
||||
# Download package and extract to web volume
|
||||
RUN curl -o roundcubemail.tar.gz -SL https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBEMAIL_VERSION}/roundcubemail-${ROUNDCUBEMAIL_VERSION}-complete.tar.gz \
|
||||
&& curl -o roundcubemail.tar.gz.asc -SL https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBEMAIL_VERSION}/roundcubemail-${ROUNDCUBEMAIL_VERSION}-complete.tar.gz.asc \
|
||||
&& export GNUPGHOME="$(mktemp -d)" \
|
||||
&& gpg --keyserver ha.pool.sks-keyservers.net --recv-keys F3E4C04BB3DB5D4215C45F7F5AB2BAA141C4F7D5 \
|
||||
&& gpg --batch --verify roundcubemail.tar.gz.asc roundcubemail.tar.gz \
|
||||
&& rm -r "$GNUPGHOME" roundcubemail.tar.gz.asc \
|
||||
&& tar -xzf roundcubemail.tar.gz -C /usr/src/ \
|
||||
# upstream tarballs include ./roundcubemail-${ROUNDCUBEMAIL_VERSION}/ so this gives us /usr/src/roundcubemail-${ROUNDCUBEMAIL_VERSION}
|
||||
&& mv /usr/src/roundcubemail-${ROUNDCUBEMAIL_VERSION} /usr/src/roundcubemail \
|
||||
&& rm -rf /usr/src/roundcubemail/installer \
|
||||
&& rm roundcubemail.tar.gz
|
||||
|
||||
COPY docker-entrypoint.sh /
|
||||
|
||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||
CMD ["apache2-foreground"]
|
||||
|
@ -0,0 +1,59 @@
|
||||
# Running Roundcube in a Docker Container
|
||||
|
||||
The simplest method is to run the official image:
|
||||
|
||||
```
|
||||
docker run -e ROUNDCUBEMAIL_DEFAULT_HOST=mail -d roundcube/roundcubemail
|
||||
```
|
||||
|
||||
## Configuration/Environment Variables
|
||||
|
||||
The following env variables can be set to configure your Roundcube Docker instance:
|
||||
|
||||
`ROUNDCUBEMAIL_DEFAULT_HOST` - Hostname of the IMAP server to connect to
|
||||
|
||||
`ROUNDCUBEMAIL_DEFAULT_PORT` - IMAP port number; defaults to `143`
|
||||
|
||||
`ROUNDCUBEMAIL_SMTP_SERVER` - Hostname of the SMTP server to send mails
|
||||
|
||||
`ROUNDCUBEMAIL_SMTP_PORT` - SMTP port number; defaults to `587`
|
||||
|
||||
`ROUNDCUBEMAIL_PLUGINS` - List of built-in plugins to activate. Defaults to `archive,zipdownload`
|
||||
|
||||
By default, the image will use a local SQLite database for storing user account metadata.
|
||||
It'll be created inside the `/var/www/html` volume and can be backed up from there. Please note that
|
||||
this option should not be used for production.
|
||||
|
||||
### Connect to a MySQL Database
|
||||
|
||||
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`
|
||||
|
||||
`MYSQL_ENV_MYSQL_USER` - The database username for Roundcube; defaults to `root`
|
||||
|
||||
`MYSQL_ENV_MYSQL_PASSWORD` - The password for the database connection or
|
||||
`MYSQL_ENV_MYSQL_ROOT_PASSWORD` - if the database username is `root`
|
||||
|
||||
`MYSQL_ENV_MYSQL_DATABASE` - 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.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
## Building a Docker Container
|
||||
|
||||
Use the `Dockerfile` in this directory to build you own Docker image.
|
||||
It pulls the latest build of Roundcube Webmail from the Github download page and builds it on top of a `php:7.1-apache` Docker image.
|
||||
|
||||
Build it from this directory with
|
||||
|
||||
```
|
||||
docker build -t roundcubemail
|
||||
```
|
||||
|
@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
# PWD=`pwd`
|
||||
|
||||
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
||||
if ! [ -e index.php -a -e bin/installto.sh ]; then
|
||||
echo >&2 "roundcubemail not found in $PWD - copying now..."
|
||||
if [ "$(ls -A)" ]; then
|
||||
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
|
||||
( set -x; ls -A; sleep 10 )
|
||||
fi
|
||||
tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf -
|
||||
sed -i 's/mod_php5.c/mod_php7.c/' .htaccess
|
||||
echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD"
|
||||
fi
|
||||
|
||||
if [ ! -z "${!MYSQL_ENV_MYSQL_*}" ]; then
|
||||
: "${ROUNDCUBEMAIL_DB_TYPE:=mysql}"
|
||||
: "${ROUNDCUBEMAIL_DB_HOST:=${MYSQL_ENV_MYSQL_HOST:-mysql}}"
|
||||
: "${ROUNDCUBEMAIL_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
|
||||
if [ "$ROUNDCUBEMAIL_DB_USER" = 'root' ]; then
|
||||
: "${ROUNDCUBEMAIL_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD}}"
|
||||
else
|
||||
: "${ROUNDCUBEMAIL_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD}}"
|
||||
fi
|
||||
: "${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}}"
|
||||
else
|
||||
# use local SQLite DB in /var/www/html/db
|
||||
: "${ROUNDCUBEMAIL_DB_DIR:=$PWD/db}"
|
||||
: "${ROUNDCUBEMAIL_DSNW:=sqlite:///$ROUNDCUBEMAIL_DB_DIR/sqlite.db?mode=0646}"
|
||||
|
||||
mkdir -p $ROUNDCUBEMAIL_DB_DIR
|
||||
chown www-data:www-data $ROUNDCUBEMAIL_DB_DIR
|
||||
fi
|
||||
|
||||
: "${ROUNDCUBEMAIL_DEFAULT_HOST:=localhost}"
|
||||
: "${ROUNDCUBEMAIL_DEFAULT_PORT:=143}"
|
||||
: "${ROUNDCUBEMAIL_SMTP_SERVER:=localhost}"
|
||||
: "${ROUNDCUBEMAIL_SMTP_PORT:=587}"
|
||||
: "${ROUNDCUBEMAIL_PLUGINS:=archive,zipdownload}"
|
||||
: "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}"
|
||||
: "${ROUNDCUBEMAIL_LOG_DIR:=/var/log/roundcubemail}"
|
||||
|
||||
if [ ! -e config/config.inc.php ]; then
|
||||
ROUNDCUBEMAIL_PLUGINS_PHP=`echo "${ROUNDCUBEMAIL_PLUGINS}" | sed -E "s/[, ]+/', '/"`
|
||||
mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR}
|
||||
mkdir -p ${ROUNDCUBEMAIL_LOG_DIR} && chown www-data ${ROUNDCUBEMAIL_LOG_DIR}
|
||||
touch config/config.inc.php
|
||||
|
||||
echo "Write config to $PWD/config/config.inc.php"
|
||||
echo "<?php
|
||||
\$config['db_dsnw'] = '${ROUNDCUBEMAIL_DSNW}';
|
||||
\$config['db_dsnr'] = '${ROUNDCUBEMAIL_DSNR}';
|
||||
\$config['default_host'] = '${ROUNDCUBEMAIL_DEFAULT_HOST}';
|
||||
\$config['default_port'] = '${ROUNDCUBEMAIL_DEFAULT_PORT}';
|
||||
\$config['smtp_server'] = '${ROUNDCUBEMAIL_SMTP_SERVER}';
|
||||
\$config['smtp_port'] = '${ROUNDCUBEMAIL_SMTP_PORT}';
|
||||
\$config['log_dir'] = '${ROUNDCUBEMAIL_LOG_DIR}';
|
||||
\$config['temp_dir'] = '${ROUNDCUBEMAIL_TEMP_DIR}';
|
||||
\$config['plugins'] = ['${ROUNDCUBEMAIL_PLUGINS_PHP}'];
|
||||
?>" | tee config/config.inc.php
|
||||
|
||||
# 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
|
||||
else
|
||||
echo "WARNING: $PWD/config/config.inc.php already exists."
|
||||
echo "ROUNDCUBEMAIL_* environment variables have been ignored."
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$@"
|
Loading…
Reference in New Issue