From 6987a33f83ef4240c2cfc6515d0936fd8b68c8f1 Mon Sep 17 00:00:00 2001 From: Snider Date: Wed, 1 Oct 2025 20:19:06 +0100 Subject: [PATCH] Add multi-arch Docker build and manifest to CI workflow Refactors the build-docker GitHub Actions workflow to build and push Docker images for both amd64 and arm64 architectures using a matrix strategy. Adds a manifest job to create and push a multi-arch manifest for the lthn/chain image, supporting both 'testnet' and 'latest' tags based on input. --- .github/workflows/build-docker.yml | 87 +++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 0a88fab3..f240fe23 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -14,39 +14,90 @@ on: default: testnet required: false type: string +env: + LTHN_TAG: ${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }} jobs: build: - name: "lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }}" - runs-on: ubuntu-22.04 + runs-on: ${{ matrix.runner }} + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-latest + tag: ${{ env.LTHN_TAG }}-amd64 + platform: linux/amd64 + - arch: arm64 + runner: ubuntu-arm + tag: ${{ env.LTHN_TAG }}-arm64 + platform: linux/arm64 steps: - - name: Checkout Project - uses: actions/checkout@v4.2.2 - with: - fetch-depth: 0 - submodules: recursive + - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to DockerHub + - name: Log in to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - id: docker_build + - name: Build and push image uses: docker/build-push-action@v6 with: + context: . file: utils/docker/images/lthn-chain/Dockerfile - context: ${{ github.workspace }} push: true - build-args: | - BUILD_TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }} - THREADS=2 - BUILD_TARGET=gcc-linux-x86_64 - BUILD_LOCAL=1 - tags: lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }} + platforms: ${{ matrix.platform }} + tags: lthn/chain:${{ matrix.tag }} + manifest: + needs: build + runs-on: ubuntu-latest + steps: + - name: Log in to DockerHub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Create and push manifest + run: | + docker manifest create lthn/chain:${{ env.LTHN_TAG }} \ + lthn/chain:${{ env.LTHN_TAG }}-amd64 \ + lthn/chain:${{ env.LTHN_TAG }}-arm64 + docker manifest push lthn/chain:${{ env.LTHN_TAG }} +# build: +# name: "lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }}" +# runs-on: ubuntu-24.04 +# steps: +# - name: Checkout Project +# uses: actions/checkout@v4.2.2 +# with: +# fetch-depth: 0 +# submodules: recursive +# +# - name: Set up Docker Buildx +# uses: docker/setup-buildx-action@v3 +# +# - name: Login to DockerHub +# uses: docker/login-action@v3 +# with: +# username: ${{ secrets.DOCKERHUB_USERNAME }} +# password: ${{ secrets.DOCKERHUB_TOKEN }} +# +# +# - name: Build and push +# id: docker_build +# uses: docker/build-push-action@v6 +# with: +# file: utils/docker/images/lthn-chain/Dockerfile +# context: ${{ github.workspace }} +# push: true +# build-args: | +# BUILD_TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }} +# THREADS=2 +# BUILD_LOCAL=1 +# tags: lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }} +#