From ed8c6c3bf220b68e39063b7d5fe7e6d0d1d6e782 Mon Sep 17 00:00:00 2001 From: Derek Guenther Date: Tue, 18 Mar 2025 18:51:16 -0400 Subject: [PATCH] Build arm64 multiplatform images --- .github/workflows/docker.yml | 237 +++++++++++++++++++++++++++++++---- .github/workflows/pr.yml | 39 +++--- 2 files changed, 234 insertions(+), 42 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 18a79e60..e9c3d3da 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -17,10 +17,14 @@ env: jobs: geth: - runs-on: ubuntu-latest strategy: matrix: - arch: [linux/amd64] + settings: + - arch: linux/amd64 + runs-on: ubuntu-24.04 + - arch: linux/arm64 + runs-on: ubuntu-24.04-arm + runs-on: ${{ matrix.settings.runs-on }} steps: - name: Checkout uses: actions/checkout@v3 @@ -32,11 +36,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: ${{ matrix.arch }} - - name: Extract metadata for the Docker image id: meta uses: docker/metadata-action@v4 @@ -49,21 +48,45 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and push the Docker image + id: build uses: docker/build-push-action@v6 with: context: . file: geth/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.NAMESPACE }}/${{ env.GETH_DEPRECATED_IMAGE_NAME }},${{ env.NAMESPACE }}/${{ env.GETH_IMAGE_NAME }} labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ matrix.arch }} + platforms: ${{ matrix.settings.arch }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Prepare + run: | + platform=${{ matrix.settings.arch }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-geth-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 reth: - runs-on: ubuntu-latest strategy: matrix: - include: + settings: - arch: linux/amd64 + runs-on: ubuntu-24.04 features: jemalloc,asm-keccak,optimism + - arch: linux/arm64 + runs-on: ubuntu-24.04-arm + features: jemalloc,optimism + runs-on: ${{ matrix.settings.runs-on }} steps: - name: Checkout uses: actions/checkout@v2 @@ -86,21 +109,46 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build and push the Docker image + id: build uses: docker/build-push-action@v6 with: context: . file: reth/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.NAMESPACE }}/${{ env.RETH_IMAGE_NAME }} labels: ${{ steps.meta.outputs.labels }} build-args: | - FEATURES=${{ matrix.features }} - platforms: ${{ matrix.arch }} + FEATURES=${{ matrix.settings.features }} + platforms: ${{ matrix.settings.arch }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Prepare + run: | + platform=${{ matrix.settings.arch }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-reth-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + nethermind: - runs-on: ubuntu-latest strategy: matrix: - platform: [linux/amd64] + settings: + - arch: linux/amd64 + runs-on: ubuntu-24.04 + - arch: linux/arm64 + runs-on: ubuntu-24.04-arm + runs-on: ${{ matrix.settings.runs-on }} steps: - name: Checkout uses: actions/checkout@v2 @@ -112,11 +160,6 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: ${{ matrix.arch }} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -128,11 +171,153 @@ jobs: ${{ env.NAMESPACE }}/${{ env.NETHERMIND_IMAGE_NAME }} - name: Build and push the Docker image + id: build uses: docker/build-push-action@v6 with: context: . file: nethermind/Dockerfile - push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.NAMESPACE }}/${{ env.NETHERMIND_IMAGE_NAME }} labels: ${{ steps.meta.outputs.labels }} - platforms: ${{ matrix.arch }} + platforms: ${{ matrix.settings.arch }} + outputs: type=image,push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p ${{ runner.temp }}/digests + digest="${{ steps.build.outputs.digest }}" + touch "${{ runner.temp }}/digests/${digest#sha256:}" + + - name: Prepare + run: | + platform=${{ matrix.settings.arch }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: digests-nethermind-${{ env.PLATFORM_PAIR }} + path: ${{ runner.temp }}/digests/* + if-no-files-found: error + retention-days: 1 + + + merge-geth: + runs-on: ubuntu-latest + needs: + - geth + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-geth-* + merge-multiple: true + + - name: Log into the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.NAMESPACE }}/${{ env.GETH_DEPRECATED_IMAGE_NAME }} + ${{ env.NAMESPACE }}/${{ env.GETH_IMAGE_NAME }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.NAMESPACE }}/${{ env.GETH_DEPRECATED_IMAGE_NAME }}@sha256:%s ' *) + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.NAMESPACE }}/${{ env.GETH_IMAGE_NAME }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.NAMESPACE }}/${{ env.GETH_DEPRECATED_IMAGE_NAME }}:${{ steps.meta.outputs.version }} + docker buildx imagetools inspect ${{ env.NAMESPACE }}/${{ env.GETH_IMAGE_NAME }}:${{ steps.meta.outputs.version }} + + merge-reth: + runs-on: ubuntu-latest + needs: + - reth + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-reth-* + merge-multiple: true + + - name: Log into the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.NAMESPACE }}/${{ env.RETH_IMAGE_NAME }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.NAMESPACE }}/${{ env.RETH_IMAGE_NAME }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.NAMESPACE }}/${{ env.RETH_IMAGE_NAME }}:${{ steps.meta.outputs.version }} + + merge-nethermind: + runs-on: ubuntu-latest + needs: + - nethermind + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digests-nethermind-* + merge-multiple: true + + - name: Log into the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Extract metadata for the Docker image + id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.NAMESPACE }}/${{ env.NETHERMIND_IMAGE_NAME }} + + - name: Create manifest list and push + working-directory: ${{ runner.temp }}/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.NAMESPACE }}/${{ env.NETHERMIND_IMAGE_NAME }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.NAMESPACE }}/${{ env.NETHERMIND_IMAGE_NAME }}:${{ steps.meta.outputs.version }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b9522a75..460e40d1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -6,21 +6,20 @@ on: jobs: geth: - runs-on: ubuntu-latest strategy: matrix: - arch: [linux/amd64] + settings: + - arch: linux/amd64 + runs-on: ubuntu-24.04 + - arch: linux/arm64 + runs-on: ubuntu-24.04-arm + runs-on: ${{ matrix.settings.runs-on }} steps: - name: Checkout uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: ${{ matrix.arch }} - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -30,15 +29,19 @@ jobs: context: . file: geth/Dockerfile push: false - platforms: ${{ matrix.arch }} + platforms: ${{ matrix.settings.arch }} reth: - runs-on: ubuntu-latest strategy: matrix: - include: + settings: - arch: linux/amd64 + runs-on: ubuntu-24.04 features: jemalloc,asm-keccak,optimism + - arch: linux/arm64 + runs-on: ubuntu-24.04-arm + features: jemalloc,optimism + runs-on: ${{ matrix.settings.runs-on}} steps: - name: Checkout uses: actions/checkout@v3 @@ -53,14 +56,18 @@ jobs: file: reth/Dockerfile push: false build-args: | - FEATURES=${{ matrix.features }} - platforms: ${{ matrix.arch }} + FEATURES=${{ matrix.settings.features }} + platforms: ${{ matrix.settings.arch }} nethermind: - runs-on: ubuntu-latest strategy: matrix: - arch: [linux/amd64] + settings: + - arch: linux/amd64 + runs-on: ubuntu-24.04 + - arch: linux/arm64 + runs-on: ubuntu-24.04-arm + runs-on: ${{ matrix.settings.runs-on}} steps: - name: Checkout uses: actions/checkout@v3 @@ -69,9 +76,9 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build the Docker image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: . file: nethermind/Dockerfile push: false - platforms: ${{ matrix.arch }} + platforms: ${{ matrix.settings.arch }}