forked from lthn/blockchain
Add multi-arch Docker build support and Makefile targets
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.
This commit is contained in:
parent
dea8becdd9
commit
66a7b597f4
3 changed files with 94 additions and 6 deletions
63
.github/workflows/build-docker.yml
vendored
63
.github/workflows/build-docker.yml
vendored
|
|
@ -1,6 +1,7 @@
|
|||
name: Docker
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
|
|
@ -19,6 +20,23 @@ 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
|
||||
|
|
@ -35,18 +53,55 @@ jobs:
|
|||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
|
||||
- name: Build and push
|
||||
- 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_TARGET=gcc-linux-x86_64
|
||||
BUILD_LOCAL=1
|
||||
tags: lthn/chain:${{ inputs.chain-network == 'testnet' && 'testnet' || 'latest' }}
|
||||
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
|
||||
|
|
|
|||
23
Makefile
23
Makefile
|
|
@ -75,6 +75,7 @@ PROFILES := $(patsubst cmake/profiles/%,%,$(wildcard cmake/profiles/*))
|
|||
SORTED_PROFILES := $(sort $(PROFILES))
|
||||
CONAN_CACHE := $(CURDIR)/build/sdk
|
||||
DEFAULT_CONAN_PROFILE := $(CONAN_CACHE)/profiles/default
|
||||
CC_DOCKER_FILE?=utils/docker/images/lthn-chain/Dockerfile
|
||||
|
||||
all: help
|
||||
|
||||
|
|
@ -159,7 +160,27 @@ docs-dev: configure
|
|||
|
||||
docker-chain-node:
|
||||
@echo "Building docker image: lthn/chain"
|
||||
docker build utils/docker/images/lthn-chain -t lthn/chain $(CURDIR)
|
||||
docker buildx build -f $(CC_DOCKER_FILE) -t lthn/chain $(CURDIR)
|
||||
|
||||
docker-cc-linux-amd64:
|
||||
docker buildx build -f $(CC_DOCKER_FILE) --target build-artifacts --output type=local,dest=build/cc-linux-amd64 --platform linux/amd64 $(CURDIR)
|
||||
|
||||
docker-cc-linux-armv7:
|
||||
docker buildx build -f $(CC_DOCKER_FILE) --target build-artifacts --output type=local,dest=build/cc-linux-armv7 --platform linux/arm/v7 $(CURDIR)
|
||||
|
||||
docker-cc-linux-arm64v8:
|
||||
docker buildx build -f $(CC_DOCKER_FILE) --target build-artifacts --output type=local,dest=build/cc-linux-arm64v8 --platform linux/arm64/v8 $(CURDIR)
|
||||
|
||||
docker-cc-linux-ppc64le:
|
||||
docker buildx build -f $(CC_DOCKER_FILE) --target build-artifacts --output type=local,dest=build/cc-linux-ppc64le --platform linux/ppc64le $(CURDIR)
|
||||
|
||||
docker-cc-linux-riscv64:
|
||||
docker buildx build -f $(CC_DOCKER_FILE) --target build-artifacts --output type=local,dest=build/cc-linux-riscv64 --platform linux/riscv64 $(CURDIR)
|
||||
|
||||
docker-cc-linux-s390x:
|
||||
docker buildx build -f $(CC_DOCKER_FILE) --target build-artifacts --output type=local,dest=build/cc-linux-s390x --platform linux/s390x $(CURDIR)
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
rm -rf build
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ ARG BUILD_TARGET=gcc-linux-x86_64
|
|||
ARG BUILD_FOLDER=build/release
|
||||
ARG BUILD_TYPE=Release
|
||||
ARG BUILD_TESTNET=1
|
||||
ARG USE_CUSTOM_PROFILE=0
|
||||
|
||||
|
||||
ENV CONAN_HOME=/root/sdk
|
||||
|
|
@ -41,7 +42,18 @@ WORKDIR /code
|
|||
|
||||
RUN conan profile detect --name=default --force
|
||||
|
||||
RUN conan install . --output-folder=${BUILD_FOLDER} --build=missing -s build_type=${BUILD_TYPE} -pr:h=/code/cmake/profiles/$BUILD_TARGET
|
||||
#RUN conan install . --output-folder=${BUILD_FOLDER} --build=missing -s build_type=${BUILD_TYPE} -pr:h=/code/cmake/profiles/$BUILD_TARGET
|
||||
|
||||
RUN set -eux; \
|
||||
BCMD="conan install . \
|
||||
--output-folder=${BUILD_FOLDER} \
|
||||
--build=missing \
|
||||
-s build_type=${BUILD_TYPE}"; \
|
||||
if [ "${USE_CUSTOM_PROFILE}" = "1" ]; then \
|
||||
BCMD="$BCMD -pr:h=/code/cmake/profiles/${BUILD_TARGET}"; \
|
||||
fi; \
|
||||
echo "Running: $BCMD"; \
|
||||
eval $BCMD;
|
||||
|
||||
RUN cmake -S /code -B ${BUILD_FOLDER} -DCMAKE_TOOLCHAIN_FILE=${BUILD_FOLDER}/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DTESTNET=${BUILD_TESTNET}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue