forked from lthn/blockchain
This update enhances the Docker build workflow to support multiple architectures (amd64, arm64, armv7, ppc64le, riscv64, s390x) using buildx and matrix builds in GitHub Actions. The Makefile now includes new targets for building and exporting artifacts for each supported architecture. The Dockerfile is updated to allow conditional use of custom Conan profiles via a new USE_CUSTOM_PROFILE build argument.
107 lines
3.2 KiB
YAML
107 lines
3.2 KiB
YAML
name: Docker
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
on:
|
|
workflow_call:
|
|
secrets:
|
|
DOCKERHUB_USERNAME:
|
|
required: true
|
|
DOCKERHUB_TOKEN:
|
|
required: true
|
|
inputs:
|
|
chain-network:
|
|
description: "The network to use, can either be testnet, stagenet or mainnet"
|
|
default: testnet
|
|
required: false
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
name: "lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }}"
|
|
runs-on: ubuntu-22.04
|
|
strategy:
|
|
matrix:
|
|
platform: [ linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le, linux/riscv64, linux/s390x ]
|
|
include:
|
|
- platform: linux/amd64
|
|
arch_tag: amd64
|
|
- platform: linux/arm64
|
|
arch_tag: arm64
|
|
- platform: linux/arm/v7
|
|
arch_tag: armv7
|
|
- platform: linux/ppc64le
|
|
arch_tag: ppc64le
|
|
- platform: linux/riscv64
|
|
arch_tag: riscv64
|
|
- platform: linux/s390x
|
|
arch_tag: s390x
|
|
|
|
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 ${{ matrix.platform }}
|
|
id: docker_build
|
|
continue-on-error: true
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: utils/docker/images/lthn-chain/Dockerfile
|
|
context: ${{ github.workspace }}
|
|
platforms: ${{ matrix.platform }}
|
|
push: true
|
|
build-args: |
|
|
BUILD_TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }}
|
|
THREADS=2
|
|
BUILD_LOCAL=1
|
|
USE_CUSTOM_PROFILE=0
|
|
tags: lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet-' || '' }}${{ matrix.arch_tag }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
finalize_manifest:
|
|
needs: build
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
|
|
- name: Set up 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
|
|
id: docker_final
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
file: utils/docker/images/lthn-chain/Dockerfile
|
|
context: ${{ github.workspace }}
|
|
platforms: "linux/amd64, linux/arm64, linux/arm/v7, linux/ppc64le, linux/riscv64, linux/s390x"
|
|
push: true
|
|
build-args: |
|
|
BUILD_TESTNET=${{ inputs.chain-network == 'testnet' && '1' || '0' }}
|
|
THREADS=2
|
|
BUILD_LOCAL=1
|
|
USE_CUSTOM_PROFILE=0
|
|
tags: lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|