Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-arch docker builder #3138

Merged
merged 4 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 136 additions & 0 deletions .github/workflows/nimbus_docker_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Nimbus
# Copyright (c) 2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
# http://opensource.org/licenses/MIT)
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.

name: Build Docker Images

on:
push:
branches:
- 'master'
paths-ignore:
- 'fluffy/**'
- '**/*.md'
- '.github/workflows/fluffy*.yml'
- 'nimbus_verified_proxy/**'
- '.github/workflows/nimbus_verified_proxy.yml'

workflow_dispatch:

env:
REGISTRY_IMAGE: ${{ secrets.DOCKERHUB_USERNAME }}/nimbus-eth1

jobs:
build:
strategy:
fail-fast: false
matrix:
target:
- os: linux
cpu: amd64
- os: linux
cpu: arm64
include:
- target:
cpu: amd64
builder: ubuntu-latest
- target:
cpu: arm64
builder: ubuntu-24.04-arm
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }}'
runs-on: ${{ matrix.builder }}
steps:
- name: Prepare
run: |
platform=${{ matrix.target.os }}/${{ matrix.target.cpu }}
# Replace '/' with '-' to create a unique identifier for this platform
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Checkout Repository
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ env.REGISTRY_IMAGE }}
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: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=sha,prefix={{branch}}-

- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON"
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2024 Status Research & Development GmbH
# Copyright (c) 2024-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
Expand All @@ -15,13 +15,13 @@ SHELL ["/bin/bash", "-c"]
RUN apt-get clean && apt update \
&& apt -y install curl build-essential git-lfs librocksdb-dev

RUN ldd --version ldd
RUN ldd --version

ADD . /root/nimbus-eth1

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

# --------------------------------- #
# Starting new image to reduce size #
Expand All @@ -33,7 +33,7 @@ RUN apt-get clean && apt update \
&& apt -y install build-essential librocksdb-dev
RUN apt update && apt -y upgrade

RUN ldd --version ldd
RUN ldd --version

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

Expand Down
Loading