fix composer no longer installs EGroupware apps (runs plugins) as root and npm install fails silent on network errors / timeouts

This commit is contained in:
ralf 2024-04-30 13:14:41 +02:00
parent a65abb3940
commit 2361d690bc

View File

@ -1,6 +1,6 @@
################################################################################
##
## EGroupware FPM container using Ubuntu 20.04 and PHP 8.1 from ondrej/php PPA
## EGroupware FPM container using Ubuntu 20.04, NodeJS 20 and PHP 8.2 from ondrej/php PPA
##
################################################################################
ARG ARCH=
@ -8,7 +8,10 @@ FROM ${ARCH}ubuntu:20.04
MAINTAINER rb@egroupware.org
ARG VERSION=dev-master
ARG PHP_VERSION=8.1
ARG PHP_VERSION=8.2
# Set environment variable for non-interactive install
ARG DEBIAN_FRONTEND=noninteractive
ARG TARGETPLATFORM
# keeping build-arg in environment for entrypoint.sh
ENV VERSION=$VERSION
@ -56,7 +59,7 @@ RUN set -e \
&& ln -s /dev/stderr /var/log/php$PHP_VERSION-fpm.log \
&& update-alternatives --install /usr/sbin/php-fpm php-fpm /usr/sbin/php-fpm$PHP_VERSION 5 \
# install tools to build EGroupware
&& apt-get install -y rsync zip curl sudo cron patch \
&& apt-get install -y xz-utils rsync zip curl sudo cron patch \
&& bash -c \
'EXPECTED_SIGNATURE=$(curl https://composer.github.io/installer.sig); \
curl https://getcomposer.org/installer > composer-setup.php; \
@ -74,20 +77,32 @@ exit $RESULT' \
&& cd /usr/share \
# not all dependencies already allow PHP 8.x, thought what we use from them works
&& bash -c "[[ $PHP_VERSION =~ ^8\..* ]]" && COMPOSER_EXTRA=--ignore-platform-reqs || true \
&& composer.phar create-project $COMPOSER_EXTRA --prefer-dist --no-scripts --no-dev egroupware/egroupware:$VERSION \
&& COMPOSER_ALLOW_SUPERUSER=1 composer.phar create-project $COMPOSER_EXTRA --prefer-dist --no-scripts --no-dev egroupware/egroupware:$VERSION \
# clean up and remove caches
&& composer.phar clear-cache \
&& rm -f /usr/local/bin/composer.phar \
&& rm -f /usr/local/bin/composer.phar
RUN set -e \
&& cd /usr/share/egroupware \
# install nodejs 16.x PPA (Shoelace requires >= 14.17, Ubuntu 22.04 only has 12.x)
&& curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
&& apt-get install -y nodejs \
# nodejs PPA does NOT exist for ppc64le, therefore we need to install npm separate, as not included in stock nodejs on Ubuntu
&& test -f /usr/bin/npm || apt-get install -y npm \
# install nodejs 20.x (Shoelace requires >= 14.17, Ubuntu 22.04 only has 12.x) \
&& if [ "$TARGETPLATFORM" = "linux/ppc64le" ]; then \
dist_node_v20=https://nodejs.org/dist/latest-v20.x/ \
dist_node_v20_ppc64le=$(curl $dist_node_v20|grep ppc64le.tar.xz|cut -d'"' -f2) \
curl $dist_node_v20$dist_node_v20_ppc64le | tar --directory=/usr/local/ -xJvf - ; \
else \
mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs libatomic1 ; \
fi \
&& npm config set fetch-retries 5 \
&& npm install -g grunt-cli \
# npm install fails "silent" on network timeouts, retry until it works
&& until grunt; do sleep 5; npm install -g grunt-cli; done \
&& mkdir chunks \
&& npm install \
&& grunt \
&& mkdir chunks && npm run build \
# npm install fails "silent" on network timeouts, retry until it works
&& until npm run build; do sleep 5; npm install; done \
# clean up and remove caches
&& npm uninstall -g grunt-cli \
&& npm cache clear --force \