Skip to content
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
8 changes: 7 additions & 1 deletion .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ inputs:
description: "The arguments that are sent to the dockerfile to built. Format ARG=value"
required: false
default: ""
platforms:
description: "Comma-separated list of platforms to build for"
required: false
default: "linux/amd64"
Comment on lines +30 to +33
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the description is stale. This is not a list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although in most cases it'd be a single platform (for perfomance issues), it can technically be a list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also addressed Copilot comments


outputs:
artifact_path:
Expand All @@ -52,7 +56,8 @@ runs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
- id: build-image
name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
Expand All @@ -63,6 +68,7 @@ runs:
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: ${{ inputs.build_args }}
platforms: ${{ inputs.platforms }}

# Since we're exporting the image as a tar, we need to load it manually as well
- name: Load image locally
Expand Down
24 changes: 8 additions & 16 deletions .github/workflows/tag_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,17 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download Docker images
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2

- name: Retag Docker images
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:l2
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}-l2
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }} \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}-l2 \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:l2 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.PREV_TAG }}-l2

- name: Push retagged Docker images
run: |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_TAG }}-l2
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:l2

publish-apt:
needs: [retag_docker_images]
uses: lambdaclass/ethrex-apt/.github/workflows/publish-apt.yml@main
Expand Down
71 changes: 57 additions & 14 deletions .github/workflows/tag_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,25 @@ jobs:
path: ethrex-contracts.tar.gz

build-docker:
name: "Build and publish ethrex docker image"
runs-on: ubuntu-latest
name: "Build ethrex docker images"
strategy:
matrix:
platform:
- ubuntu-latest
- ubuntu-22.04-arm
include:
- platform: ubuntu-latest
arch: amd64
- platform: ubuntu-22.04-arm
arch: arm64
runs-on: ${{ matrix.platform }}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker supports cross-platform builds using QEMU, but in my tests there were to much slower than build them in parallel natively

outputs:
tag: ${{ steps.tag_version.outputs.tag }}

# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
attestations: write
id-token: write
actions: write

steps:
- name: Checkout code
Expand All @@ -338,38 +347,71 @@ jobs:
- name: Free Disk Space
uses: ./.github/actions/free-disk

- name: Format name
- name: Determine tag version
id: tag_version
run: |
# For branch builds (main) we want docker images tagged as 'main'. For tag pushes
# use the tag name (stripped of a leading 'v').
if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then
echo "TAG_VERSION=main" >> $GITHUB_ENV
echo "tag=main" >> $GITHUB_OUTPUT
else
echo "TAG_VERSION=$(echo ${{ github.ref_name }} | tr -d v)" >> $GITHUB_ENV
echo "tag=$(echo ${{ github.ref_name }} | tr -d v)" >> $GITHUB_OUTPUT
fi

# Pushes to ghcr.io/lambdaclass/ethrex
- name: Build and push L1 Docker image
id: push_l1
- name: Build L1 Docker image
id: build_l1
uses: ./.github/actions/build-docker
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
push: ${{ github.event_name != 'workflow_dispatch'}}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-${{ matrix.arch }}
platforms: linux/${{ matrix.arch }}

# Pushes to ghcr.io/lambdaclass/ethrex
- name: Build and push L2 Docker image
id: push_l2
- name: Build L2 Docker image
id: build_l2
uses: ./.github/actions/build-docker
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
push: ${{ github.event_name != 'workflow_dispatch'}}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-l2
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_VERSION }}-l2-${{ matrix.arch }}
build_args: BUILD_FLAGS=--features l2,l2-sql
platforms: linux/${{ matrix.arch }}

publish-docker:
name: "Create and push multi-arch Docker manifests"
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_dispatch'}}
needs: build-docker

permissions:
packages: write
contents: read

steps:
- name: Login to Docker registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create multi-arch image
run: |
docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-docker.outputs.tag }} \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-docker.outputs.tag }}-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-docker.outputs.tag }}-arm64

docker buildx imagetools create \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-docker.outputs.tag }}-l2 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-docker.outputs.tag }}-l2-amd64 \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.build-docker.outputs.tag }}-l2-arm64

# Creates a release on GitHub with the binaries
finalize-release:
Expand All @@ -378,6 +420,7 @@ jobs:
- build-ethrex
- build-ethrex-guest
- build-docker
- publish-docker
- package-contracts
- package-ethrex-guest
runs-on: ubuntu-latest
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ FROM chef AS builder
COPY --from=planner /ethrex/recipe.json recipe.json
RUN cargo chef cook --release --recipe-path recipe.json

RUN curl -L -o /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.8.29/solc-static-linux \
RUN if [ "$(uname -m)" = aarch64 ]; \
then \
SOLC_URL=https://github.com/nikitastupin/solc/raw/refs/heads/main/linux/aarch64/solc-v0.8.29;\
else \
SOLC_URL=https://github.com/ethereum/solidity/releases/download/v0.8.29/solc-static-linux; \
fi \
&& curl -L -o /usr/bin/solc $SOLC_URL \
&& chmod +x /usr/bin/solc

COPY benches ./benches
Expand Down