From 24cec8cab461c54bdd576d81987eecf10565559b Mon Sep 17 00:00:00 2001 From: JesusPerez Date: Tue, 29 Jun 2021 20:11:00 +0100 Subject: [PATCH] chore: update 1.4.11 src & pipeline --- pipeline/pipe-resource.yaml | 2 +- repo-config.yaml | 3 +- src/Dockerfile | 40 ++++++++++++------- src/docker-compose.yml | 66 +++---------------------------- src/docker-entrypoint.sh | 77 +++++++++++++++++++++++++------------ 5 files changed, 85 insertions(+), 103 deletions(-) diff --git a/pipeline/pipe-resource.yaml b/pipeline/pipe-resource.yaml index 7980ae9..ef330b7 100644 --- a/pipeline/pipe-resource.yaml +++ b/pipeline/pipe-resource.yaml @@ -7,7 +7,7 @@ spec: type: image params: - name: url - value: termas.librecloud.online/termas_librecloud/roundcubemail:1.4.6 + value: termas.librecloud.online/termas_librecloud/roundcubemail:1.4.11 --- apiVersion: tekton.dev/v1alpha1 kind: PipelineResource diff --git a/repo-config.yaml b/repo-config.yaml index ffd8175..fa8332f 100644 --- a/repo-config.yaml +++ b/repo-config.yaml @@ -1,4 +1,3 @@ - Active: true # Active: false # to not follow up webhook workflow @@ -8,7 +7,7 @@ Source: roundcubemail-docker/fpm-alpine # Name - Version, etc Name: roundcubemail -Version: 1.4.6 +Version: 1.4.11 # To get latest IMAGE_NAME: roundcube/roundcubemail diff --git a/src/Dockerfile b/src/Dockerfile index 3881827..86f1807 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,27 +1,31 @@ -FROM php:7.3-fpm-alpine +FROM php:7.4-fpm-alpine LABEL maintainer="Thomas Bruederli " -# entrypoint.sh and cron.sh dependencies +# entrypoint.sh and installto.sh dependencies RUN set -ex; \ \ apk add --no-cache \ bash \ coreutils \ + rsync \ tzdata RUN set -ex; \ \ apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ icu-dev \ + imagemagick-dev \ libjpeg-turbo-dev \ libpng-dev \ libzip-dev \ + libtool \ openldap-dev \ postgresql-dev \ sqlite-dev \ ; \ \ - docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure gd; \ docker-php-ext-configure ldap; \ docker-php-ext-install \ exif \ @@ -33,6 +37,8 @@ RUN set -ex; \ pdo_sqlite \ zip \ ; \ + pecl install imagick; \ + docker-php-ext-enable imagick; \ \ runDeps="$( \ scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ @@ -40,17 +46,24 @@ RUN set -ex; \ | sort -u \ | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ )"; \ - apk add --virtual .roundcubemail-phpext-rundeps $runDeps; \ + apk add --virtual .roundcubemail-phpext-rundeps imagemagick $runDeps; \ apk del .build-deps +# add composer.phar +ADD https://getcomposer.org/installer /tmp/composer-installer.php + +RUN php /tmp/composer-installer.php --install-dir=/usr/local/bin/; \ + rm /tmp/composer-installer.php + + # expose these volumes -#VOLUME /var/roundcube/config -#VOLUME /var/roundcube/db -#VOLUME /var/www/html -#VOLUME /tmp/roundcube-temp +VOLUME /var/roundcube/config +VOLUME /var/roundcube/db +VOLUME /var/www/html +VOLUME /tmp/roundcube-temp # Define Roundcubemail version -ENV ROUNDCUBEMAIL_VERSION 1.4.6 +ENV ROUNDCUBEMAIL_VERSION 1.4.11 # Download package and extract to web volume RUN set -ex; \ @@ -63,15 +76,14 @@ RUN set -ex; \ export GNUPGHOME="$(mktemp -d)"; \ # workaround for "Cannot assign requested address", see e.g. https://github.com/inversepath/usbarmory-debian-base_image/issues/9 echo "disable-ipv6" > "$GNUPGHOME/dirmngr.conf"; \ - # ha.pool.sks-keyservers.net seems to be unreliable, use pgp.mit.edu as fallback - gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys F3E4C04BB3DB5D4215C45F7F5AB2BAA141C4F7D5 || gpg --batch --keyserver pgp.mit.edu --recv-keys F3E4C04BB3DB5D4215C45F7F5AB2BAA141C4F7D5; \ + curl -fSL https://roundcube.net/download/pubkey.asc | gpg --batch --import -; \ gpg --batch --verify roundcubemail.tar.gz.asc roundcubemail.tar.gz; \ - tar -xf roundcubemail.tar.gz -C /usr/src/; \ gpgconf --kill all; \ + mkdir /usr/src/roundcubemail; \ + tar -xf roundcubemail.tar.gz -C /usr/src/roundcubemail --strip-components=1 --no-same-owner; \ rm -r "$GNUPGHOME" roundcubemail.tar.gz.asc roundcubemail.tar.gz; \ - # 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; \ + chown -R www-data:www-data /usr/src/roundcubemail/logs; \ apk del .fetch-deps # include the wait-for-it.sh script diff --git a/src/docker-compose.yml b/src/docker-compose.yml index dac7526..eae40ad 100644 --- a/src/docker-compose.yml +++ b/src/docker-compose.yml @@ -1,10 +1,9 @@ version: "2" services: - roundcube: + roundcubemail: build: ./ - container_name: roundcube - #restart: always + container_name: roundcubemail depends_on: - roundcubedb links: @@ -21,9 +20,8 @@ services: - ROUNDCUBEMAIL_DB_PASSWORD=roundcube # same as pgsql POSTGRES_PASSWORD env name roundcubedb: - image: postgres:latest + image: postgres:alpine container_name: roundcubedb - restart: always ports: - 5432:5432 volumes: @@ -36,67 +34,13 @@ services: roundcubenginx: image: nginx:latest container_name: roundcubenginx - restart: always ports: - 80:80 - # If you need SSL connection - # - '443:443' depends_on: - - roundcube + - roundcubemail links: - - roundcube + - roundcubemail volumes: - /srv/roundcube/html:/var/www/html - # TODO Provide a custom nginx conf - #- ./nginx.conf:/etc/nginx/nginx.conf:ro - # If you need SSL connection, you can provide your own certificates - # - ./certs:/etc/letsencrypt - # - ./certs-data:/data/letsencrypt environment: - NGINX_HOST=localhost # set your local domain or your live domain - # - NGINX_CGI=roundcube:9000 # same as roundcube container name - - # Sample mail server to use with RoundCube: https://github.com/tomav/docker-mailserver -# mailserver: -# image: tvial/docker-mailserver:latest -# hostname: mail -# domainname: -# container_name: mail -# restart: always -# ports: -# # receiving email from other mailservers -# - "25:25" -# # SSL & TLS Client email submission (SMTP) -# - "465:465" -# - "587:587" -# # StartTLS & TLS/SSL IMAP client -# - "143:143" -# - "993:993" -# # POP3 & TLS/SSL POP3 client -# - "110:110" -# - "995:995" -# # Manage Sieve port -# - "4190:4190" -# environment: -# - DMS_DEBUG=0 -# - ONE_DIR=1 -# - ENABLE_CLAMAV=1 -# - ENABLE_FAIL2BAN=1 -# - ENABLE_POSTGREY=1 -# - ENABLE_MANAGESIEVE=1 -# # If you need SSL connection, you can provide your own certificates -# #- SSL_TYPE=manual -# #- SSL_CERT_PATH=/etc/letsencrypt/fullchain.pem -# #- SSL_KEY_PATH=/etc/letsencrypt/privkey.pem -# cap_add: -# - NET_ADMIN -# - SYS_PTRACE -# volumes: -# - /srv/mail/data:/var/mail -# - /srv/mail/state:/var/mail-state -# # For proper delivery, generate DKIM keys in /srv/mail/setup -# - /srv/mail/setup:/tmp/docker-mailserver -# - /etc/localtime:/etc/localtime:ro -# - /etc/timezone:/etc/timezone:ro -# # If you need SSL connection, you can provide your own certificates -# # - ./certs:/etc/letsencrypt diff --git a/src/docker-entrypoint.sh b/src/docker-entrypoint.sh index 4a45bee..a476dc5 100755 --- a/src/docker-entrypoint.sh +++ b/src/docker-entrypoint.sh @@ -4,6 +4,7 @@ # PWD=`pwd` if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then + # docroot is empty if ! [ -e index.php -a -e bin/installto.sh ]; then echo >&2 "roundcubemail not found in $PWD - copying now..." if [ "$(ls -A)" ]; then @@ -12,6 +13,12 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then fi tar cf - --one-file-system -C /usr/src/roundcubemail . | tar xf - echo >&2 "Complete! ROUNDCUBEMAIL has been successfully copied to $PWD" + # update Roundcube in docroot + else + INSTALLDIR=`pwd` + echo >&2 "roundcubemail found in $INSTALLDIR - installing update..." + (cd /usr/src/roundcubemail && bin/installto.sh -y $INSTALLDIR) + composer.phar update --no-dev fi if [ -f /run/secrets/roundcube_db_user ]; then @@ -46,9 +53,9 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then /wait-for-it.sh ${ROUNDCUBEMAIL_DB_HOST}:${ROUNDCUBEMAIL_DB_PORT} -t 30 else - # use local SQLite DB in /var/www/html/db + # use local SQLite DB in /var/roundcube/db : "${ROUNDCUBEMAIL_DB_TYPE:=sqlite}" - : "${ROUNDCUBEMAIL_DB_DIR:=$PWD/db}" + : "${ROUNDCUBEMAIL_DB_DIR:=/var/roundcube/db}" : "${ROUNDCUBEMAIL_DB_NAME:=sqlite}" : "${ROUNDCUBEMAIL_DSNW:=${ROUNDCUBEMAIL_DB_TYPE}:///$ROUNDCUBEMAIL_DB_DIR/${ROUNDCUBEMAIL_DB_NAME}.db?mode=0646}" @@ -65,37 +72,50 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then : "${ROUNDCUBEMAIL_TEMP_DIR:=/tmp/roundcube-temp}" if [ ! -e config/config.inc.php ]; then - ROUNDCUBEMAIL_PLUGINS_PHP=`echo "${ROUNDCUBEMAIL_PLUGINS}" | sed -E "s/[, ]+/', '/g"` - ROUNDCUBEMAIL_DES_KEY=`test -f /run/secrets/roundcube_des_key && cat /run/secrets/roundcube_des_key || head /dev/urandom | base64 | head -c 24` + GENERATED_DES_KEY=`head /dev/urandom | base64 | head -c 24` touch config/config.inc.php - echo "Write config to $PWD/config/config.inc.php" + echo "Write root config to $PWD/config/config.inc.php" echo " config/config.inc.php - for fn in `ls /var/roundcube/config/*.php 2>/dev/null || true`; do - echo "include('$fn');" >> config/config.inc.php - done - - # 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 "Failed to initialize databse. Please run $PWD/bin/initdb.sh manually." - else - echo "WARNING: $PWD/config/config.inc.php already exists." - echo "ROUNDCUBEMAIL_* environment variables have been ignored." + elif ! grep -q "config.docker.inc.php" config/config.inc.php; then + echo "include(__DIR__ . '/config.docker.inc.php');" >> config/config.inc.php fi + ROUNDCUBEMAIL_PLUGINS_PHP=`echo "${ROUNDCUBEMAIL_PLUGINS}" | sed -E "s/[, ]+/', '/g"` + echo "Write Docker config to $PWD/config/config.docker.inc.php" + echo " config/config.docker.inc.php + + if [ -e /run/secrets/roundcube_des_key ]; then + echo "\$config['des_key'] = file_get_contents('/run/secrets/roundcube_des_key');" >> config/config.docker.inc.php + elif [ ! -z "${ROUNDCUBEMAIL_DES_KEY}" ]; then + echo "\$config['des_key'] = getenv('ROUNDCUBEMAIL_DES_KEY');" >> config/config.docker.inc.php + fi + + # include custom config files + for fn in `ls /var/roundcube/config/*.php 2>/dev/null || true`; do + echo "include('$fn');" >> config/config.docker.inc.php + done + + # initialize or update DB + bin/initdb.sh --dir=$PWD/SQL --create || bin/updatedb.sh --dir=$PWD/SQL --package=roundcube || echo "Failed to initialize database. Please run $PWD/bin/initdb.sh and $PWD/bin/updatedb.sh manually." + if [ ! -z "${ROUNDCUBEMAIL_TEMP_DIR}" ]; then mkdir -p ${ROUNDCUBEMAIL_TEMP_DIR} && chown www-data ${ROUNDCUBEMAIL_TEMP_DIR} fi @@ -104,6 +124,13 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then echo "upload_max_filesize=${ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE}" >> /usr/local/etc/php/conf.d/roundcube-override.ini echo "post_max_size=${ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE}" >> /usr/local/etc/php/conf.d/roundcube-override.ini fi + + : "${ROUNDCUBEMAIL_LOCALE:=en_US.UTF-8 UTF-8}" + + if [ -e /usr/sbin/locale-gen ] && [ ! -z "${ROUNDCUBEMAIL_LOCALE}" ]; then + echo "${ROUNDCUBEMAIL_LOCALE}" > /etc/locale.gen + /usr/sbin/locale-gen + fi fi exec "$@"