From 42e45c349a540db36f70dd65548934e6d6b7d211 Mon Sep 17 00:00:00 2001 From: Torben Nehmer Date: Sat, 7 Oct 2023 10:52:56 +0200 Subject: [PATCH] Update build pipeline to 1.6.3 --- Dockerfile | 50 ++++++++-- build-container.sh | 2 +- build-rootfs.sh | 10 +- src/scripts/wait-for-it.sh | 182 +++++++++++++++++++++++++++++++++++++ 4 files changed, 228 insertions(+), 16 deletions(-) create mode 100755 src/scripts/wait-for-it.sh diff --git a/Dockerfile b/Dockerfile index 265591f..85566c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-apache +FROM php:8.1-apache LABEL maintainer="Torben Nehmer " RUN set -ex; \ @@ -11,16 +11,20 @@ RUN set -ex; \ libicu-dev \ libjpeg62-turbo-dev \ libldap2-dev \ + libmagickwand-dev \ libpng-dev \ libpq-dev \ libsqlite3-dev \ libzip-dev \ + libpspell-dev \ + libonig-dev \ + libldap-common \ # ISPConfig requirement libxml2-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ - docker-php-ext-configure gd ; \ + docker-php-ext-configure gd --with-jpeg --with-freetype ; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install \ exif \ @@ -31,15 +35,19 @@ RUN set -ex; \ pdo_pgsql \ pdo_sqlite \ zip \ + pspell \ # ISPConfig requirement soap \ ; \ + pecl install imagick redis; \ + docker-php-ext-enable imagick opcache redis; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies apt-mark auto '.*' > /dev/null; \ apt-mark manual $savedAptMark; \ - ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ - | awk '/=>/ { print $3 }' \ + extdir="$(php -r 'echo ini_get("extension_dir");')"; \ + ldd "$extdir"/*.so \ + | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -r dpkg-query -S \ | cut -d: -f1 \ @@ -48,16 +56,40 @@ RUN set -ex; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get clean ;\ - rm -rf /var/lib/apt/lists/* ;\ - \ - # enable mod_rewrite - a2enmod rewrite + ldd "$extdir"/*.so | grep -qzv "=> not found" || (echo "Sanity check failed: missing libraries:"; ldd "$extdir"/*.so | grep " => not found"; exit 1); \ + ldd "$extdir"/*.so | grep -q "libzip.so.* => .*/libzip.so.*" || (echo "Sanity check failed: libzip.so is not referenced"; ldd "$extdir"/*.so; exit 1); \ + err="$(php --version 3>&1 1>&2 2>&3)"; \ + [ -z "$err" ] || (echo "Sanity check failed: php returned errors; $err"; exit 1;); + +# installto.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + aspell \ + aspell-en \ + aspell-de \ + aspell-fr \ + rsync \ + unzip \ + locales \ + ; \ + \ + echo "de_DE.UTF-8 UTF-8" > /etc/locale.gen ; \ + /usr/sbin/locale-gen ; \ + rm -rf /var/lib/apt/lists/* ; \ + mkdir -p /usr/src/roundcubemail/logs ; \ + chown -R www-data:www-data /usr/src/roundcubemail/logs ; + +COPY --from=composer:2 /usr/bin/composer /usr/bin/composer + +RUN a2enmod rewrite # expose these volumes VOLUME /var/roundcube/config # Define Roundcubemail version -ENV ROUNDCUBEMAIL_VERSION 1.4.13 +ENV ROUNDCUBEMAIL_VERSION 1.6.3 # Set the entry point ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/build-container.sh b/build-container.sh index d9d2ed5..55e0918 100755 --- a/build-container.sh +++ b/build-container.sh @@ -2,5 +2,5 @@ set -ex -docker pull php:7.4-apache +docker pull php:8.1-apache docker build --force-rm --no-cache -t nathan/roundcube -f Dockerfile build diff --git a/build-rootfs.sh b/build-rootfs.sh index eeda235..ad53ec6 100755 --- a/build-rootfs.sh +++ b/build-rootfs.sh @@ -3,7 +3,7 @@ set -ex # Configuration options you usually edit go here -ROUNDCUBEMAIL_VERSION=1.4.13 +ROUNDCUBEMAIL_VERSION=1.6.3 CHECK_GPG=false CLEAN_INTERMEDIATES=false CONTAINER_VOLUME_CONFIG=/var/roundcube/config @@ -72,11 +72,9 @@ if [ "$CHECK_GPG" = true ]; then fi fi -# Extract the file into a temporary location and clean up behind us -tar -xzf ${ROUNDCUBE_DOWNLOAD} -C ${TMPDIR} - -# upstream tarballs include ./roundcubemail-${ROUNDCUBEMAIL_VERSION}/ so this gives us TMPDIR/roundcubemail-${ROUNDCUBEMAIL_VERSION} -mv ${TMPDIR}/roundcubemail-${ROUNDCUBEMAIL_VERSION} ${ROUNDCUBE_SRC} +# Extract the file +mkdir -p ${ROUNDCUBE_SRC} +tar -xzf ${ROUNDCUBE_DOWNLOAD} -C ${ROUNDCUBE_SRC} --strip-components=1 --no-same-owner # Clean up the source tree for later use rm -rf ${ROUNDCUBE_SRC}/installer diff --git a/src/scripts/wait-for-it.sh b/src/scripts/wait-for-it.sh new file mode 100755 index 0000000..d990e0d --- /dev/null +++ b/src/scripts/wait-for-it.sh @@ -0,0 +1,182 @@ +#!/usr/bin/env bash +# Use this script to test if a given TCP host/port are available + +WAITFORIT_cmdname=${0##*/} + +echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi } + +usage() +{ + cat << USAGE >&2 +Usage: + $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args] + -h HOST | --host=HOST Host or IP under test + -p PORT | --port=PORT TCP port under test + Alternatively, you specify the host and port as host:port + -s | --strict Only execute subcommand if the test succeeds + -q | --quiet Don't output any status messages + -t TIMEOUT | --timeout=TIMEOUT + Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit 1 +} + +wait_for() +{ + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + else + echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout" + fi + WAITFORIT_start_ts=$(date +%s) + while : + do + if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then + nc -z $WAITFORIT_HOST $WAITFORIT_PORT + WAITFORIT_result=$? + else + (echo -n > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1 + WAITFORIT_result=$? + fi + if [[ $WAITFORIT_result -eq 0 ]]; then + WAITFORIT_end_ts=$(date +%s) + echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds" + break + fi + sleep 1 + done + return $WAITFORIT_result +} + +wait_for_wrapper() +{ + # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692 + if [[ $WAITFORIT_QUIET -eq 1 ]]; then + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + else + timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT & + fi + WAITFORIT_PID=$! + trap "kill -INT -$WAITFORIT_PID" INT + wait $WAITFORIT_PID + WAITFORIT_RESULT=$? + if [[ $WAITFORIT_RESULT -ne 0 ]]; then + echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT" + fi + return $WAITFORIT_RESULT +} + +# process arguments +while [[ $# -gt 0 ]] +do + case "$1" in + *:* ) + WAITFORIT_hostport=(${1//:/ }) + WAITFORIT_HOST=${WAITFORIT_hostport[0]} + WAITFORIT_PORT=${WAITFORIT_hostport[1]} + shift 1 + ;; + --child) + WAITFORIT_CHILD=1 + shift 1 + ;; + -q | --quiet) + WAITFORIT_QUIET=1 + shift 1 + ;; + -s | --strict) + WAITFORIT_STRICT=1 + shift 1 + ;; + -h) + WAITFORIT_HOST="$2" + if [[ $WAITFORIT_HOST == "" ]]; then break; fi + shift 2 + ;; + --host=*) + WAITFORIT_HOST="${1#*=}" + shift 1 + ;; + -p) + WAITFORIT_PORT="$2" + if [[ $WAITFORIT_PORT == "" ]]; then break; fi + shift 2 + ;; + --port=*) + WAITFORIT_PORT="${1#*=}" + shift 1 + ;; + -t) + WAITFORIT_TIMEOUT="$2" + if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi + shift 2 + ;; + --timeout=*) + WAITFORIT_TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + WAITFORIT_CLI=("$@") + break + ;; + --help) + usage + ;; + *) + echoerr "Unknown argument: $1" + usage + ;; + esac +done + +if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then + echoerr "Error: you need to provide a host and port to test." + usage +fi + +WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15} +WAITFORIT_STRICT=${WAITFORIT_STRICT:-0} +WAITFORIT_CHILD=${WAITFORIT_CHILD:-0} +WAITFORIT_QUIET=${WAITFORIT_QUIET:-0} + +# Check to see if timeout is from busybox? +WAITFORIT_TIMEOUT_PATH=$(type -p timeout) +WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH) + +WAITFORIT_BUSYTIMEFLAG="" +if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then + WAITFORIT_ISBUSY=1 + # Check if busybox timeout uses -t flag + # (recent Alpine versions don't support -t anymore) + if timeout &>/dev/stdout | grep -q -e '-t '; then + WAITFORIT_BUSYTIMEFLAG="-t" + fi +else + WAITFORIT_ISBUSY=0 +fi + +if [[ $WAITFORIT_CHILD -gt 0 ]]; then + wait_for + WAITFORIT_RESULT=$? + exit $WAITFORIT_RESULT +else + if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then + wait_for_wrapper + WAITFORIT_RESULT=$? + else + wait_for + WAITFORIT_RESULT=$? + fi +fi + +if [[ $WAITFORIT_CLI != "" ]]; then + if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then + echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess" + exit $WAITFORIT_RESULT + fi + exec "${WAITFORIT_CLI[@]}" +else + exit $WAITFORIT_RESULT +fi