Merge pull request #72 from PrivateBin/move-edge-build

run all image builds in parallel, letting all builds conclude
This commit is contained in:
El RIDO 2021-10-02 19:50:17 +02:00 committed by GitHub
commit 607c4248b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 16 deletions

View file

@ -1,4 +1,4 @@
name: Deploy multi-architecture Docker images for privatebin with buildx
name: Build & Deploy container image
on:
schedule:
@ -12,6 +12,12 @@ on:
jobs:
buildx:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
base-image: [stable, edge]
destination-image: [nginx-fpm-alpine, fs, pdo, gcs]
name: ${{ matrix.destination-image }} image / ${{ matrix.base-image }} release
steps:
- name: Checkout
uses: actions/checkout@v2
@ -27,4 +33,4 @@ jobs:
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: ./buildx.sh ${{ github.event_name }}
run: ./buildx.sh ${{ github.event_name }} ${{ matrix.destination-image }} ${{ matrix.base-image }}

View file

@ -5,6 +5,9 @@
set -euxo pipefail
EVENT=$1
IMAGE=$2
EDGE=false
[ "$3" = edge ] && EDGE=true
build_image() {
local PUSH
@ -27,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 ] || \
@ -44,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
@ -59,12 +53,28 @@ main() {
PUSH=false
fi
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
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"
image_build_arguments | while read -r IMAGE BUILD_ARGS ; do
build_image $PUSH --tag "$IMAGE:latest" --tag "$IMAGE:$TAG" --tag "${IMAGE}:${TAG%%-*}" "$BUILD_ARGS"
if [ "$EDGE" = true ] ; then
sed -e 's/^FROM alpine:.*$/FROM alpine:edge/' Dockerfile > Dockerfile.edge
build_image $PUSH -f Dockerfile.edge --tag "$IMAGE:edge" "$BUILD_ARGS"
done
else
build_image $PUSH --tag "$IMAGE:latest" --tag "$IMAGE:$TAG" --tag "${IMAGE}:${TAG%%-*}" "$BUILD_ARGS"
fi
rm -f Dockerfile.edge "$HOME/.docker/config.json"
}