From b50cdc96e00a5d8bbc7cf25b72a3a6e97c0df2e7 Mon Sep 17 00:00:00 2001 From: init4samwise Date: Wed, 11 Mar 2026 15:22:13 +0000 Subject: [PATCH] feat: add native arm64 builds using parallel runners Replace QEMU-emulated multi-arch builds with native runners: - Build amd64 on ubuntu-latest - Build arm64 on ubuntu-24.04-arm (native GitHub arm64 runner) - Merge digests into multi-arch manifest This avoids timeout issues from QEMU emulation while providing proper arm64 images. --- .github/workflows/publish-init4-docker.yml | 107 +++++++++++++++++---- 1 file changed, 89 insertions(+), 18 deletions(-) diff --git a/.github/workflows/publish-init4-docker.yml b/.github/workflows/publish-init4-docker.yml index 950c4acb9b03..a4f02f1db043 100644 --- a/.github/workflows/publish-init4-docker.yml +++ b/.github/workflows/publish-init4-docker.yml @@ -14,15 +14,57 @@ permissions: packages: write jobs: - build-and-push: - name: Build and push Docker image + build-amd64: + name: Build amd64 runs-on: ubuntu-latest + timeout-minutes: 120 + outputs: + digest: ${{ steps.build.outputs.digest }} steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract version from tag + id: version + run: | + VERSION=${GITHUB_REF_NAME#v} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "short_sha=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/amd64 + push: true + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=amd64 + cache-to: type=gha,scope=amd64,mode=max + build-args: | + BLOCKSCOUT_VERSION=${{ github.ref_name }}+commit.${{ steps.version.outputs.short_sha }} + RELEASE_VERSION=${{ steps.version.outputs.version }} + + build-arm64: + name: Build arm64 + runs-on: ubuntu-24.04-arm + timeout-minutes: 120 + outputs: + digest: ${{ steps.build.outputs.digest }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -41,6 +83,36 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT echo "short_sha=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_OUTPUT + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + file: ./docker/Dockerfile + platforms: linux/arm64 + push: true + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha,scope=arm64 + cache-to: type=gha,scope=arm64,mode=max + build-args: | + BLOCKSCOUT_VERSION=${{ github.ref_name }}+commit.${{ steps.version.outputs.short_sha }} + RELEASE_VERSION=${{ steps.version.outputs.version }} + + merge: + name: Create multi-arch manifest + runs-on: ubuntu-latest + needs: [build-amd64, build-arm64] + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata for Docker id: meta uses: docker/metadata-action@v5 @@ -51,17 +123,16 @@ jobs: type=semver,pattern={{major}}.{{minor}} type=raw,value=latest - - name: Build and push Docker image - uses: docker/build-push-action@v6 - with: - context: . - file: ./docker/Dockerfile - push: true - platforms: linux/amd64,linux/arm64 - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - build-args: | - BLOCKSCOUT_VERSION=${{ github.ref_name }}+commit.${{ steps.version.outputs.short_sha }} - RELEASE_VERSION=${{ steps.version.outputs.version }} + - name: Create manifest list and push + working-directory: /tmp + run: | + # Create and push manifest for each tag + for tag in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); do + docker buildx imagetools create -t "$tag" \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-amd64.outputs.digest }}" \ + "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@${{ needs.build-arm64.outputs.digest }}" + done + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest