fully unwind & parallelize loop

This commit is contained in:
El RIDO 2021-09-29 20:03:42 +02:00
parent 76234b4a1e
commit c841e76c7e
2 changed files with 28 additions and 23 deletions

View file

@ -5,8 +5,9 @@
set -euxo pipefail
EVENT=$1
IMAGE=$2
EDGE=false
[ "$2" = edge ] && EDGE=true
[ "$3" = edge ] && EDGE=true
build_image() {
local PUSH
@ -29,15 +30,6 @@ docker_login() {
--password-stdin
}
image_build_arguments() {
cat<<!
privatebin/fs --build-arg ALPINE_PACKAGES= --build-arg COMPOSER_PACKAGES=
privatebin/pdo --build-arg ALPINE_PACKAGES=php8-pdo_mysql,php8-pdo_pgsql --build-arg COMPOSER_PACKAGES=
privatebin/gcs --build-arg ALPINE_PACKAGES=php8-openssl
privatebin/nginx-fpm-alpine
!
}
is_image_push_required() {
[ "$EVENT" != pull_request ] && { \
[ "$GITHUB_REF" != refs/heads/master ] || \
@ -46,7 +38,7 @@ is_image_push_required() {
}
main() {
local PUSH TAG IMAGE BUILD_ARGS
local PUSH TAG BUILD_ARGS
if [ "$EVENT" = schedule ] ; then
TAG=nightly
@ -61,16 +53,28 @@ main() {
PUSH=false
fi
if [ "$EDGE" = true ] ; then
case "$IMAGE" in
fs)
BUILD_ARGS="--build-arg ALPINE_PACKAGES= --build-arg COMPOSER_PACKAGES="
;;
pdo)
BUILD_ARGS="--build-arg ALPINE_PACKAGES=php8-pdo_mysql,php8-pdo_pgsql --build-arg COMPOSER_PACKAGES="
;;
gcs)
BUILD_ARGS="--build-arg ALPINE_PACKAGES=php8-openssl"
;;
*)
BUILD_ARGS=""
;;
esac
IMAGE="privatebin/$IMAGE"
if [ "$EDGE" = false ] ; then
build_image $PUSH --tag "$IMAGE:latest" --tag "$IMAGE:$TAG" --tag "${IMAGE}:${TAG%%-*}" "$BUILD_ARGS"
else
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
build_image $PUSH -f Dockerfile.edge --tag "$IMAGE:edge" "$BUILD_ARGS"
fi
image_build_arguments | while read -r IMAGE BUILD_ARGS ; do
if [ "$EDGE" = false ] ; then
build_image $PUSH --tag "$IMAGE:latest" --tag "$IMAGE:$TAG" --tag "${IMAGE}:${TAG%%-*}" "$BUILD_ARGS"
else
build_image $PUSH -f Dockerfile.edge --tag "$IMAGE:edge" "$BUILD_ARGS"
fi
done
rm -f Dockerfile.edge "$HOME/.docker/config.json"
}