From 59c5b152b271adca5d82610ed3484df3c104b4c4 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Fri, 11 Nov 2022 09:10:45 +0100 Subject: [PATCH] Switch to using set -euxo pipefail for better error handling -e immediately exit when a command fails. No further commands are processed. -o pipefail, if a series of piped commands fail, do NOt return the last commands returncode, but DO return the return code of the failing command in the pipeline series -u, raise an error when an unset variable is used. Not using this results in an empty value being used and the script being executed differently without you knowing why. -x, print each command before executing it. Actual arguments are expanded. So you see the command with the actual parameter values. This is printed in red in the buildx log output. --- webmails/roundcube/Dockerfile | 37 +++++++++++++++++----------------- webmails/snappymail/Dockerfile | 24 ++++++++++++---------- 2 files changed, 32 insertions(+), 29 deletions(-) diff --git a/webmails/roundcube/Dockerfile b/webmails/roundcube/Dockerfile index c7da51b3..a4c4b914 100644 --- a/webmails/roundcube/Dockerfile +++ b/webmails/roundcube/Dockerfile @@ -6,33 +6,34 @@ FROM base ARG VERSION LABEL version=$VERSION -RUN apk add --no-cache \ +RUN set -euxo pipefail \ + ; apk add --no-cache \ nginx gpg gpg-agent \ php8 php8-fpm php8-mbstring php8-zip php8-xml php8-simplexml \ php8-dom php8-curl php8-exif gd php8-gd php8-iconv php8-intl php8-openssl \ php8-pdo_sqlite php8-pdo_mysql php8-pdo_pgsql php8-pdo php8-sodium libsodium php8-tidy php8-pecl-uuid \ php8-pspell php8-pecl-imagick php8-opcache php8-session php8-sockets php8-fileinfo \ - && rm /etc/nginx/http.d/default.conf \ - && rm /etc/php8/php-fpm.d/www.conf \ - && mkdir -p /run/nginx \ - && mkdir -p /conf + ; rm /etc/nginx/http.d/default.conf \ + ; rm /etc/php8/php-fpm.d/www.conf \ + ; mkdir -p /run/nginx \ + ; mkdir -p /conf ENV ROUNDCUBE_URL https://github.com/roundcube/roundcubemail/releases/download/1.5.3/roundcubemail-1.5.3-complete.tar.gz ENV CARDDAV_URL https://github.com/mstilkerich/rcmcarddav/releases/download/v4.4.3/carddav-v4.4.3.tar.gz -RUN \ - cd /var/www \ - && curl -sL ${ROUNDCUBE_URL} | tar xz \ - && curl -sL ${CARDDAV_URL} | tar xz \ - && mv roundcubemail-* webmail \ - && mkdir -p /var/www/webmail/config \ - && mv carddav webmail/plugins/ \ - && cd webmail \ - && rm -rf CHANGELOG.md SECURITY.md INSTALL LICENSE README.md UPGRADING composer.json-dist installer composer.* \ - && ln -sf index.php /var/www/webmail/sso.php \ - && chmod -R u+w,a+rX /var/www/webmail \ - && chown -R nginx:nginx /var/www/webmail \ - && rm -rf plugins/{autologon,example_addressbook,http_authentication,krb_authentication,new_user_identity,password,redundant_attachments,squirrelmail_usercopy,userinfo,virtuser_file,virtuser_query} +RUN set -euxo pipefail \ + ; cd /var/www \ + ; curl -sL ${ROUNDCUBE_URL} | tar xz \ + ; curl -sL ${CARDDAV_URL} | tar xz \ + ; mv roundcubemail-* webmail \ + ; mkdir -p /var/www/webmail/config \ + ; mv carddav webmail/plugins/ \ + ; cd webmail \ + ; rm -rf CHANGELOG.md SECURITY.md INSTALL LICENSE README.md UPGRADING composer.json-dist installer composer.* \ + ; ln -sf index.php /var/www/webmail/sso.php \ + ; chmod -R u+w,a+rX /var/www/webmail \ + ; chown -R nginx:nginx /var/www/webmail \ + ; rm -rf plugins/{autologon,example_addressbook,http_authentication,krb_authentication,new_user_identity,password,redundant_attachments,squirrelmail_usercopy,userinfo,virtuser_file,virtuser_query} # nginx / PHP config files diff --git a/webmails/snappymail/Dockerfile b/webmails/snappymail/Dockerfile index f6770b94..35c01fca 100644 --- a/webmails/snappymail/Dockerfile +++ b/webmails/snappymail/Dockerfile @@ -34,16 +34,17 @@ LABEL version=$VERSION # xxtea (PECL) not found on alpine repo # zip php7-zip #php7-curl php7-iconv php7-json php7-xml php7-simplexml php7-dom php7-openssl php7-pdo php7-pdo_sqlite php7-mbstring \ -RUN apk add --no-cache \ +RUN set -euxo pipefail \ + ; apk add --no-cache \ nginx curl \ php8 php8-fpm php8-mbstring php8-zip php8-xml php8-simplexml \ php8-dom php8-curl php8-exif gd php8-gd php8-iconv php8-intl php8-openssl \ php8-pdo_sqlite php8-pdo php8-sodium libsodium php8-tidy php8-pecl-uuid \ - && rm /etc/nginx/http.d/default.conf \ - && rm /etc/php8/php-fpm.d/www.conf \ - && mkdir -p /run/nginx \ - && mkdir -p /var/www/webmail \ - && mkdir -p /config + ; rm /etc/nginx/http.d/default.conf \ + ; rm /etc/php8/php-fpm.d/www.conf \ + ; mkdir -p /run/nginx \ + ; mkdir -p /var/www/webmail \ + ; mkdir -p /config # nginx / PHP config files COPY config/nginx-snappymail.conf /config/nginx-snappymail.conf @@ -55,12 +56,13 @@ COPY defaults/application.ini /defaults/application.ini COPY defaults/default.ini /defaults/default.ini # Install Snappymail from source -ENV SNAPPYMAIL_URL https://github.com/the-djmaze/snappymail/releases/download/v2.13.4/snappymail-2.13.4.zip +ENV SNAPPYMAIL_URL https://github.com/the-djmaze/snappymail/releases/download/v2.13.4/snappymail-2.13.4.tar.gz -RUN cd /var/www/webmail \ - && busybox wget ${SNAPPYMAIL_URL} -O - | busybox unzip - \ - && chmod -R u+w,a+rX /var/www/webmail \ - && chown -R nginx:nginx /var/www/webmail +RUN set -euxo pipefail \ + ; cd /var/www/webmail \ + ; curl -sL ${SNAPPYMAIL_URL} | tar xz \ + ; chmod -R u+w,a+rX /var/www/webmail \ + ; chown -R nginx:nginx /var/www/webmail # SnappyMail login COPY login/include.php /var/www/webmail/include.php