From c49ae59fc3d9a313316ada4fa5b4aa0fe81a7752 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 4 Oct 2023 12:53:51 +0800 Subject: [PATCH] fix: add per image scope to gha cache (#745) * chore: scope gha cache by image tag * chore: bump action runner version * chore: add runner arch to scope * chore: stop exporting extensions cache --- .github/workflows/ami-release.yml | 16 ++++++------ .github/workflows/build-ccache.yml | 6 ++--- .github/workflows/collect-u18-binaries.yml | 27 +++++++++------------ .github/workflows/dockerhub-release-aio.yml | 10 ++++---- .github/workflows/dockerhub-release.yml | 10 ++++---- .github/workflows/package-plv8.yml | 6 ++--- .github/workflows/test.yml | 11 +++++---- Dockerfile | 2 +- 8 files changed, 42 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ami-release.yml b/.github/workflows/ami-release.yml index 209894de7..9a26571cb 100644 --- a/.github/workflows/ami-release.yml +++ b/.github/workflows/ami-release.yml @@ -35,20 +35,19 @@ jobs: with: cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml' - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: endpoint: builders - - uses: docker/build-push-action@v3 + - uses: docker/build-push-action@v5 with: - push: false load: true build-args: | ${{ steps.args.outputs.result }} target: extensions tags: supabase/postgres:extensions platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} + # No need to export extensions cache because latest depends on it - name: Extract built packages run: | mkdir -p /tmp/extensions ansible/files/extensions @@ -60,9 +59,8 @@ jobs: - id: version run: echo "${{ steps.args.outputs.result }}" | grep "postgresql" >> "$GITHUB_OUTPUT" - name: Build Postgres deb - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: - push: false load: true file: docker/Dockerfile target: pg-deb @@ -74,8 +72,8 @@ jobs: CPPFLAGS=-mcpu=${{ matrix.mcpu }} tags: supabase/postgres:deb platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ github.ref_name }}-deb + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-deb - name: Extract Postgres deb run: | mkdir -p /tmp/build ansible/files/postgres diff --git a/.github/workflows/build-ccache.yml b/.github/workflows/build-ccache.yml index 888fbbe14..f296dd62f 100644 --- a/.github/workflows/build-ccache.yml +++ b/.github/workflows/build-ccache.yml @@ -44,7 +44,7 @@ jobs: image_digest: ${{ steps.build.outputs.digest }} steps: - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: endpoint: builders - name: Configure AWS credentials - prod @@ -56,7 +56,7 @@ jobs: with: registry: public.ecr.aws - id: build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: push: true target: buildcache @@ -70,7 +70,7 @@ jobs: needs: build_image runs-on: ubuntu-latest steps: - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 - name: Configure AWS credentials - prod uses: aws-actions/configure-aws-credentials@v1 with: diff --git a/.github/workflows/collect-u18-binaries.yml b/.github/workflows/collect-u18-binaries.yml index 21116a809..569679fba 100644 --- a/.github/workflows/collect-u18-binaries.yml +++ b/.github/workflows/collect-u18-binaries.yml @@ -44,12 +44,11 @@ jobs: with: cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml' - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: - endpoint: builders - - uses: docker/build-push-action@v3 + endpoint: builders + - uses: docker/build-push-action@v5 with: - push: false load: true file: Dockerfile-u18 build-args: | @@ -57,8 +56,8 @@ jobs: target: extensions tags: supabase/postgres:extensions-u18 platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max,ignore-error=true + cache-from: type=gha,scope=${{ github.ref_name }}-extensions-u18 + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-extensions-u18,ignore-error=true - name: Extract built packages run: | @@ -71,9 +70,8 @@ jobs: - id: version run: echo "${{ steps.args.outputs.result }}" | grep "postgresql" >> "$GITHUB_OUTPUT" - name: Build Postgres deb - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: - push: false load: true file: docker/Dockerfile target: pg-deb @@ -85,8 +83,8 @@ jobs: DEB_BUILD_PROFILES=pkg.postgresql.nozstd tags: supabase/postgres:deb-u18 platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max,ignore-error=true + cache-from: type=gha,scope=${{ github.ref_name }}-deb-u18 + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-deb-u18,ignore-error=true - name: Extract Postgres deb run: | mkdir -p /tmp/build ansible/files/postgres @@ -94,11 +92,10 @@ jobs: for layer in /tmp/build/*/layer.tar; do tar xvf "$layer" -C ansible/files/postgres --strip-components 1 done - + - name: Build surrogate Docker image - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: - push: false load: true file: Dockerfile-u18 target: pg_binary_collection @@ -109,8 +106,8 @@ jobs: postgresql_release=${{ steps.version.outputs.postgresql_release }} tags: supabase/postgres:u18-binaries platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max,ignore-error=true + cache-from: type=gha,scope=${{ github.ref_name }}-u18-binaries + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-u18-binaries,ignore-error=true - name: Copy binary tarball run: | diff --git a/.github/workflows/dockerhub-release-aio.yml b/.github/workflows/dockerhub-release-aio.yml index 9da4e13a7..3664c3c02 100644 --- a/.github/workflows/dockerhub-release-aio.yml +++ b/.github/workflows/dockerhub-release-aio.yml @@ -47,7 +47,7 @@ jobs: image_digest: ${{ steps.build.outputs.digest }} steps: - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: endpoint: builders - uses: docker/login-action@v2 @@ -55,7 +55,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - id: build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: file: docker/all-in-one/Dockerfile push: true @@ -65,8 +65,8 @@ jobs: target: production tags: ${{ needs.settings.outputs.image_tag }}_${{ matrix.arch }} platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ github.ref_name }}-aio-${{ matrix.arch }} + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-aio-${{ matrix.arch }} - name: Slack Notification if: ${{ failure() }} uses: rtCamp/action-slack-notify@v2 @@ -81,7 +81,7 @@ jobs: needs: [settings, build_image] runs-on: ubuntu-latest steps: - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} diff --git a/.github/workflows/dockerhub-release.yml b/.github/workflows/dockerhub-release.yml index 1f1453c38..6af84ec55 100644 --- a/.github/workflows/dockerhub-release.yml +++ b/.github/workflows/dockerhub-release.yml @@ -40,7 +40,7 @@ jobs: image_digest: ${{ steps.build.outputs.digest }} steps: - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: endpoint: builders - uses: docker/login-action@v2 @@ -48,7 +48,7 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - id: build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: push: true build-args: | @@ -56,8 +56,8 @@ jobs: target: production tags: ${{ needs.settings.outputs.image_tag }}_${{ matrix.arch }} platforms: linux/${{ matrix.arch }} - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} - name: Slack Notification if: ${{ failure() }} uses: rtCamp/action-slack-notify@v2 @@ -72,7 +72,7 @@ jobs: needs: [settings, build_image] runs-on: ubuntu-latest steps: - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} diff --git a/.github/workflows/package-plv8.yml b/.github/workflows/package-plv8.yml index 0944eb9a8..34822d7b6 100644 --- a/.github/workflows/package-plv8.yml +++ b/.github/workflows/package-plv8.yml @@ -43,7 +43,7 @@ jobs: image_digest: ${{ steps.build.outputs.digest }} steps: - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: endpoint: builders - uses: docker/login-action@v2 @@ -52,7 +52,7 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - id: build - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v5 with: push: true target: plv8-deb @@ -64,7 +64,7 @@ jobs: needs: [settings, build_image] runs-on: ubuntu-latest steps: - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v2 with: registry: ghcr.io diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 48523ea47..f2de89a82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,20 +29,21 @@ jobs: cmd: yq 'to_entries | map(select(.value|type == "!!str")) | map(.key + "=" + .value) | join("\n")' 'ansible/vars.yml' - run: docker context create builders - - uses: docker/setup-buildx-action@v2 + - uses: docker/setup-buildx-action@v3 with: endpoint: builders - - uses: docker/build-push-action@v3 + - uses: docker/build-push-action@v5 with: - push: false load: true context: . target: production build-args: | ${{ steps.args.outputs.result }} tags: supabase/postgres:latest - cache-from: type=gha - cache-to: type=gha,mode=max + cache-from: | + type=gha,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} + type=gha,scope=${{ github.base_ref }}-latest-${{ matrix.arch }} + cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-latest-${{ matrix.arch }} - name: Start Postgres run: | diff --git a/Dockerfile b/Dockerfile index 89e948110..5bc2f35bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -# syntax=docker/dockerfile:1.5-labs +# syntax=docker/dockerfile:1.6 ARG postgresql_major=15 ARG postgresql_release=${postgresql_major}.1