Skip to content

Commit 8786ee7

Browse files
authored
multi-arch docker builder (#3138)
* multi arch docker image builder with extensible platform support * replace vars to secrets * update dockerfile * fix: lint
1 parent dbf85f1 commit 8786ee7

File tree

2 files changed

+140
-4
lines changed

2 files changed

+140
-4
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Nimbus
2+
# Copyright (c) 2025 Status Research & Development GmbH
3+
# Licensed under either of
4+
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
5+
# http://www.apache.org/licenses/LICENSE-2.0)
6+
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
7+
# http://opensource.org/licenses/MIT)
8+
# at your option. This file may not be copied, modified, or distributed except
9+
# according to those terms.
10+
11+
name: Build Docker Images
12+
13+
on:
14+
push:
15+
branches:
16+
- 'master'
17+
paths-ignore:
18+
- 'fluffy/**'
19+
- '**/*.md'
20+
- '.github/workflows/fluffy*.yml'
21+
- 'nimbus_verified_proxy/**'
22+
- '.github/workflows/nimbus_verified_proxy.yml'
23+
24+
workflow_dispatch:
25+
26+
env:
27+
REGISTRY_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/nimbus-eth1
28+
29+
jobs:
30+
build:
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
target:
35+
- os: linux
36+
cpu: amd64
37+
- os: linux
38+
cpu: arm64
39+
include:
40+
- target:
41+
cpu: amd64
42+
builder: ubuntu-latest
43+
- target:
44+
cpu: arm64
45+
builder: ubuntu-24.04-arm
46+
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
47+
runs-on: ${{ matrix.builder }}
48+
steps:
49+
- name: Prepare
50+
run: |
51+
platform=${{ matrix.target.os }}/${{ matrix.target.cpu }}
52+
# Replace '/' with '-' to create a unique identifier for this platform
53+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
54+
55+
- name: Docker meta
56+
id: meta
57+
uses: docker/metadata-action@v5
58+
with:
59+
images: ${{ env.REGISTRY_IMAGE }}
60+
61+
- name: Checkout Repository
62+
uses: actions/checkout@v4
63+
64+
- name: Login to Docker Hub
65+
uses: docker/login-action@v3
66+
with:
67+
username: ${{ secrets.DOCKERHUB_USERNAME }}
68+
password: ${{ secrets.DOCKERHUB_TOKEN }}
69+
70+
- name: Set up Docker Buildx
71+
uses: docker/setup-buildx-action@v3
72+
73+
- name: Build and push by digest
74+
id: build
75+
uses: docker/build-push-action@v6
76+
with:
77+
context: .
78+
platforms: ${{ matrix.platform }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
tags: ${{ env.REGISTRY_IMAGE }}
81+
outputs: type=image,push-by-digest=true,name-canonical=true,push=true
82+
83+
- name: Export digest
84+
run: |
85+
mkdir -p ${{ runner.temp }}/digests
86+
digest="${{ steps.build.outputs.digest }}"
87+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
88+
89+
- name: Upload digest
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: digests-${{ env.PLATFORM_PAIR }}
93+
path: ${{ runner.temp }}/digests/*
94+
if-no-files-found: error
95+
retention-days: 1
96+
97+
merge:
98+
runs-on: ubuntu-latest
99+
needs:
100+
- build
101+
steps:
102+
- name: Download digests
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: ${{ runner.temp }}/digests
106+
pattern: digests-*
107+
merge-multiple: true
108+
109+
- name: Login to Docker Hub
110+
uses: docker/login-action@v3
111+
with:
112+
username: ${{ secrets.DOCKERHUB_USERNAME }}
113+
password: ${{ secrets.DOCKERHUB_TOKEN }}
114+
115+
- name: Set up Docker Buildx
116+
uses: docker/setup-buildx-action@v3
117+
118+
- name: Docker meta
119+
id: meta
120+
uses: docker/metadata-action@v5
121+
with:
122+
images: ${{ env.REGISTRY_IMAGE }}
123+
tags: |
124+
type=ref,event=branch
125+
type=sha,prefix={{branch}}-
126+
127+
- name: Create manifest list and push
128+
working-directory: ${{ runner.temp }}/digests
129+
run: |
130+
jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON"
131+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
132+
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
133+
134+
- name: Inspect image
135+
run: |
136+
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Nimbus
2-
# Copyright (c) 2024 Status Research & Development GmbH
2+
# Copyright (c) 2024-2025 Status Research & Development GmbH
33
# Licensed under either of
44
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
55
# http://www.apache.org/licenses/LICENSE-2.0)
@@ -15,13 +15,13 @@ SHELL ["/bin/bash", "-c"]
1515
RUN apt-get clean && apt update \
1616
&& apt -y install curl build-essential git-lfs librocksdb-dev
1717

18-
RUN ldd --version ldd
18+
RUN ldd --version
1919

2020
ADD . /root/nimbus-eth1
2121

2222
RUN cd /root/nimbus-eth1 \
2323
&& make -j$(nproc) update-from-ci \
24-
&& make -j$(nproc) V=1 LOG_LEVEL=TRACE nimbus
24+
&& make -j$(nproc) V=1 nimbus
2525

2626
# --------------------------------- #
2727
# Starting new image to reduce size #
@@ -33,7 +33,7 @@ RUN apt-get clean && apt update \
3333
&& apt -y install build-essential librocksdb-dev
3434
RUN apt update && apt -y upgrade
3535

36-
RUN ldd --version ldd
36+
RUN ldd --version
3737

3838
RUN rm -f /home/user/nimbus-eth1/build/nimbus_execution_client
3939

0 commit comments

Comments
 (0)