Skip to content

Commit

Permalink
fix: add per image scope to gha cache (#745)
Browse files Browse the repository at this point in the history
* chore: scope gha cache by image tag

* chore: bump action runner version

* chore: add runner arch to scope

* chore: stop exporting extensions cache
  • Loading branch information
sweatybridge authored Oct 4, 2023
1 parent 27e5449 commit c49ae59
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 46 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/ami-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-ccache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/collect-u18-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,20 @@ 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: |
${{ steps.args.outputs.result }}
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: |
Expand All @@ -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
Expand All @@ -85,20 +83,19 @@ 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
docker save supabase/postgres:deb-u18 | tar xv -C /tmp/build
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
Expand All @@ -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: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/dockerhub-release-aio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ 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
with:
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
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/dockerhub-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ 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
with:
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: |
${{ needs.settings.outputs.build_args }}
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
Expand All @@ -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 }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/package-plv8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit c49ae59

Please sign in to comment.