From 4e738413613e1087f2c513b4df0d4e22374849bd Mon Sep 17 00:00:00 2001 From: Andy Pfister Date: Wed, 10 Jul 2024 20:33:49 +0200 Subject: [PATCH] Parameterize current Alpine build --- .github/workflows/ci.yml | 46 +++++++++++++++++++-------------- Dockerfile => Dockerfile.alpine | 0 test.sh | 5 ++-- 3 files changed, 29 insertions(+), 22 deletions(-) rename Dockerfile => Dockerfile.alpine (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b836ed..4d28767 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: + operating_system: + - alpine pg_version: - "9.5" - "9.6" @@ -40,14 +42,15 @@ jobs: - name: Build and push image uses: docker/build-push-action@v5 with: + file: "Dockerfile.${{ matrix.operating_system }}" push: true platforms: linux/amd64,linux/arm64 build-args: | "PGTARGET=16" target: "build-${{ matrix.pg_version }}" - tags: "pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}" + tags: "pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}-${{ matrix.operating_system }}" cache-to: type=inline - cache-from: type=registry,ref=pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }} + cache-from: type=registry,ref=pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}-${{ matrix.operating_system }} target-images: runs-on: ubuntu-latest @@ -57,24 +60,24 @@ jobs: env: # but still use our public caches in any case # they might be outdated, in which case a full rebuild will be triggered - TARGET_TAG: ${{ github.ref == 'refs/heads/main' && 'alpine' || 'dev-alpine' }} CACHE_FROM: | - type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-10 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-11 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-12 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-13 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-14 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-15 - type=registry,ref=pgautoupgrade/pgautoupgrade:build-16 - type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine - type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine3.19 - # we cannot access TARGET_TAG from env - # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability + type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-10-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-11-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-12-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-13-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-14-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-15-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:build-16-${{ matrix.operating_system }} + type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }} + type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }} strategy: matrix: + operating_system: + - flavor: "alpine" + version: "3.19" pg_target: - "12" - "13" @@ -99,10 +102,10 @@ jobs: - name: Build image uses: docker/build-push-action@v5 with: + file: "Dockerfile.${{ matrix.operating_system.flavor }}" load: true tags: | - "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine" - "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine3.19" + "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}" build-args: | "PGTARGET=${{ matrix.pg_target }}" cache-to: type=inline @@ -116,15 +119,17 @@ jobs: make test env: PGTARGET: ${{ matrix.pg_target }} + OS_FLAVOR: ${{ matrix.operating_system.flavor }} - name: Push image if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main' uses: docker/build-push-action@v5 with: + file: "Dockerfile.${{ matrix.operating_system.flavor }}" platforms: linux/amd64,linux/arm64 tags: | - "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine" - "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-alpine3.19" + "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}" + "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ matrix.operating_system.flavor }}${{ matrix.operating_system.version }}" build-args: | "PGTARGET=${{ matrix.pg_target }}" push: true @@ -135,6 +140,7 @@ jobs: if: github.repository == 'pgautoupgrade/docker-pgautoupgrade' && github.ref == 'refs/heads/main' && matrix.pg_target == '16' uses: docker/build-push-action@v5 with: + file: "Dockerfile.${{ matrix.operating_system.flavor }}" platforms: linux/amd64,linux/arm64 tags: | "pgautoupgrade/pgautoupgrade:latest" diff --git a/Dockerfile b/Dockerfile.alpine similarity index 100% rename from Dockerfile rename to Dockerfile.alpine diff --git a/test.sh b/test.sh index 38a9ddd..6d630cf 100755 --- a/test.sh +++ b/test.sh @@ -14,6 +14,7 @@ test_down() { test_run() { VERSION=$1 TARGET=$2 + FLAVOR=$3 # Delete any existing test PostgreSQL data if [ -d postgres-data ]; then @@ -25,7 +26,7 @@ test_run() { docker compose -f "docker-compose-pg${VERSION}.yml" run --rm server create_db # Start Redash normally, using an "autoupdate" version of PostgreSQL - TARGET_TAG="${TARGET}-alpine" docker compose -f docker-compose-pgauto.yml up --wait -d + TARGET_TAG="${TARGET}-${FLAVOR}" docker compose -f docker-compose-pgauto.yml up --wait -d # Verify the PostgreSQL data files are now the target version PGVER=$(sudo cat postgres-data/PG_VERSION) @@ -64,7 +65,7 @@ cd test || exit 1 for version in "${PG_VERSIONS[@]}"; do # Only test if the version is less than the latest version if [[ $(echo "$version < $PGTARGET" | bc) -eq 1 ]]; then - test_run "$version" "$PGTARGET" + test_run "$version" "$PGTARGET" "$OS_FLAVOR" fi done