Docker build CI triggered from @Sneh1999 of #398
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build the nitro-node and nitro-node-dev images on ARM64 and AMD64 hosts. | |
# | |
# The reason for building the ARM image natively instead of with QEMU is that | |
# the QEMU build always failed after around 40 minutes. I'm currently not sure | |
# why it failed. I did also run into insufficient space issuse on public runners | |
# so it's possible this was always the culprit. | |
# | |
# After building, the images are merged together to make a multiplatform image. | |
name: Espresso Docker build CI | |
run-name: Docker build CI triggered from @${{ github.actor }} of ${{ github.head_ref }} | |
on: | |
workflow_dispatch: | |
merge_group: | |
pull_request: | |
push: | |
branches: | |
- master | |
- develop | |
- integration | |
- celestia-integration | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+-.*" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
docker_build: | |
strategy: | |
matrix: | |
platform: [linux/amd64, linux/arm64] | |
# Don't run arm build on PRs, "exclude:" is processed before "include:", | |
# so we avoid using `include:`. | |
exclude: | |
- platform: ${{ github.event_name == 'pull_request' && 'linux/arm64' }} | |
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || 'buildjet-4vcpu-ubuntu-2204-arm' }} | |
steps: | |
- uses: cargo-bins/cargo-binstall@main | |
if: ${{ runner.arch != 'ARM64' }} | |
- name: Make more disk space available on public runner | |
if: ${{ runner.arch != 'ARM64' }} | |
run: | | |
# rmz seems to be faster at deleting files than rm | |
cargo binstall -y rmz | |
sudo mv /home/runner/.cargo/bin/rmz /usr/local/bin/rmz | |
echo "Available storage before:" | |
sudo df -h | |
echo | |
sudo rmz -f $AGENT_TOOLSDIRECTORY | |
sudo rmz -f /opt/az | |
sudo rmz -f /opt/ghc | |
sudo rmz -f /opt/google | |
sudo rmz -f /opt/microsoft | |
sudo rmz -f /opt/pipx | |
sudo rmz -f /usr/lib/mono | |
sudo rmz -f /usr/local/julia* | |
sudo rmz -f /usr/local/lib/android | |
sudo rmz -f /usr/local/lib/node_modules | |
sudo rmz -f /usr/local/share/boost | |
sudo rmz -f /usr/local/share/chromium | |
sudo rmz -f /usr/local/share/powershell | |
sudo rmz -f /usr/share/az_* | |
sudo rmz -f /usr/share/dotnet | |
sudo rmz -f /usr/share/gradle-* | |
sudo rmz -f /usr/share/swift | |
echo "Available storage after:" | |
sudo df -h | |
echo | |
- name: Fix submodule permissions check | |
run: | | |
git config --global --add safe.directory '*' | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Container Repo | |
uses: docker/login-action@v3 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build nitro-node image | |
uses: ./.github/actions/docker-image | |
with: | |
context: . | |
file: Dockerfile | |
images: ghcr.io/espressosystems/nitro-espresso-integration/nitro-node | |
target: nitro-node | |
platforms: ${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
- name: Build nitro-node-dev image | |
uses: ./.github/actions/docker-image | |
id: nitro-node-dev | |
with: | |
context: . | |
file: Dockerfile | |
images: ghcr.io/espressosystems/nitro-espresso-integration/nitro-node-dev | |
target: nitro-node-dev | |
platforms: ${{ matrix.platform }} | |
push: ${{ github.event_name != 'pull_request' }} | |
- name: Check available space after CI run | |
if: "!cancelled()" | |
run: | | |
sudo df -h | |
# Merge the AMD64 and ARM64 images into the final (multiplatform) image. | |
# | |
# For documentation refer to | |
# https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners | |
# Only building for AMD64 | |
merge_into_multiplatform_images: | |
# We only build the ARM images for non-PR builds, so skip this job if we're on PRs. | |
if: github.event_name != 'pull_request' | |
needs: | |
- docker_build | |
strategy: | |
matrix: | |
target: [nitro-node, nitro-node-dev] | |
include: | |
- target: nitro-node | |
image: ghcr.io/espressosystems/nitro-espresso-integration/nitro-node | |
- target: nitro-node-dev | |
image: ghcr.io/espressosystems/nitro-espresso-integration/nitro-node-dev | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Github Container Repo | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Remove digests dir | |
run: | | |
rm -rf "${{ runner.temp }}/digests" | |
- name: Download digests | |
uses: actions/download-artifact@v3 | |
with: | |
name: "${{ matrix.target }}-digests" | |
path: "${{ runner.temp }}/digests" | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ matrix.image }} | |
- name: Create manifest list and push | |
working-directory: "${{ runner.temp }}/digests" | |
run: | | |
# Count the number of files in the directory | |
file_count=$(find . -type f | wc -l) | |
if [ "$file_count" -ne 2 ]; then | |
echo "Should have exactly 2 digests to combine, something went wrong" | |
ls -lah | |
exit 1 | |
fi | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ matrix.image }}@sha256:%s ' *) | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect ${{ matrix.image }}:${{ steps.meta.outputs.version }} |