From 0a72feb35a2117b09d6ef83d07cf65b647dd1834 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Mon, 11 May 2026 16:45:31 +0200 Subject: [PATCH 1/3] Use native runners --- .github/workflows/docker.yml | 109 +++++++++++++++++++++++++++-------- 1 file changed, 84 insertions(+), 25 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4185b95..5f412e6 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -10,19 +10,25 @@ on: env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + REGISTRY_IMAGE: ghcr.io/${{ github.repository }} jobs: - build-and-push-image: + build-image: if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} - runs-on: ubuntu-latest + name: Build image (${{ matrix.platform }}) + runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - - module: metaproxy - dockerfile: Dockerfile - image: ghcr.io/${{ github.repository }} + - platform: linux/amd64 + platform-pair: linux-amd64 + runner: ubuntu-24.04 + cache-scope: amd64 + - platform: linux/arm64 + platform-pair: linux-arm64 + runner: ubuntu-24.04-arm + cache-scope: arm64 permissions: contents: read packages: write @@ -44,7 +50,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ matrix.image }} + images: ${{ env.REGISTRY_IMAGE }} tags: | type=schedule type=ref,event=branch @@ -52,28 +58,81 @@ jobs: type=ref,event=pr type=sha - - name: Cache Docker layers - uses: actions/cache@v4 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ hashFiles(matrix.dockerfile) }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Build and push Docker image + - name: Build and push Docker image by digest + id: build uses: docker/build-push-action@v6 with: context: . - file: ${{ matrix.dockerfile }} - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} + file: Dockerfile + platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache,mode=max + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache-scope }} + cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache-scope }},mode=max + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-${{ matrix.platform-pair }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge-image: + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + name: Merge image manifests + runs-on: ubuntu-24.04 + needs: + - build-image + permissions: + contents: read + packages: write + + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: digests-* + merge-multiple: true + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=sha + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create \ + $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + + - name: Inspect image + run: docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} From f7b75cb2e98d2ac9cc1e1f2fed72ab562df88347 Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Mon, 11 May 2026 16:52:54 +0200 Subject: [PATCH 2/3] CoPilot --- .github/workflows/docker.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5f412e6..28ea538 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -22,13 +22,13 @@ jobs: matrix: include: - platform: linux/amd64 - platform-pair: linux-amd64 + platform_pair: linux-amd64 runner: ubuntu-24.04 - cache-scope: amd64 + cache_scope: amd64 - platform: linux/arm64 - platform-pair: linux-arm64 + platform_pair: linux-arm64 runner: ubuntu-24.04-arm - cache-scope: arm64 + cache_scope: arm64 permissions: contents: read packages: write @@ -70,8 +70,8 @@ jobs: platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache-scope }} - cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache-scope }},mode=max + cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache_scope }} + cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache_scope }},mode=max - name: Export digest run: | @@ -82,7 +82,7 @@ jobs: - name: Upload digest uses: actions/upload-artifact@v4 with: - name: digests-${{ matrix.platform-pair }} + name: digests-${{ matrix.platform_pair }} path: /tmp/digests/* if-no-files-found: error retention-days: 1 From 587db6acbf6568626a08ae2f9b518f4877f2931f Mon Sep 17 00:00:00 2001 From: Jakub Skoczen Date: Mon, 11 May 2026 17:03:29 +0200 Subject: [PATCH 3/3] Use GHA cache --- .github/workflows/docker.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 28ea538..c13e79b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -15,20 +15,18 @@ env: jobs: build-image: if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} - name: Build image (${{ matrix.platform }}) + name: Build image (${{ matrix.os }}/${{ matrix.arch }}) runs-on: ${{ matrix.runner }} strategy: fail-fast: false matrix: include: - - platform: linux/amd64 - platform_pair: linux-amd64 + - os: linux + arch: amd64 runner: ubuntu-24.04 - cache_scope: amd64 - - platform: linux/arm64 - platform_pair: linux-arm64 + - os: linux + arch: arm64 runner: ubuntu-24.04-arm - cache_scope: arm64 permissions: contents: read packages: write @@ -67,11 +65,11 @@ jobs: with: context: . file: Dockerfile - platforms: ${{ matrix.platform }} + platforms: ${{ matrix.os }}/${{ matrix.arch }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true - cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache_scope }} - cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:buildcache-${{ matrix.cache_scope }},mode=max + cache-from: type=gha,scope=metaproxy-${{ matrix.os }}-${{ matrix.arch }} + cache-to: type=gha,scope=metaproxy-${{ matrix.os }}-${{ matrix.arch }},mode=max - name: Export digest run: | @@ -82,7 +80,7 @@ jobs: - name: Upload digest uses: actions/upload-artifact@v4 with: - name: digests-${{ matrix.platform_pair }} + name: digests-${{ matrix.os }}-${{ matrix.arch }} path: /tmp/digests/* if-no-files-found: error retention-days: 1