Skip to content

Commit

Permalink
cache and parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Oct 22, 2024
1 parent df57aed commit a21702e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/docker-git.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ on:

env:
REPO_NAME: ${{ github.repository_owner }}/reth
IMAGE_NAME: ${{ github.repository_owner }}/reth
OP_IMAGE_NAME: ${{ github.repository_owner }}/op-reth
CARGO_TERM_COLOR: always
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/reth
OP_DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/op-reth
DOCKER_USERNAME: ${{ github.actor }}
GIT_SHA: ${{ github.sha }}

Expand All @@ -24,6 +20,19 @@ jobs:
permissions:
packages: write
contents: read
strategy:
matrix:
image-name:
- reth
- op-reth
include:
- image-name: reth
docker_image_name: ghcr.io/${{ github.repository_owner }}/reth
make_target: docker-build-push-git-sha
- image-name: op-reth
docker_image_name: ghcr.io/${{ github.repository_owner }}/op-reth
make_target: op-docker-build-push-git-sha

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -38,7 +47,6 @@ jobs:
run: |
docker run --privileged --rm tonistiigi/binfmt --install arm64,amd64
docker buildx create --use --name cross-builder
- name: Build and push the git-sha-tagged reth image
run: make PROFILE=maxperf GIT_SHA=$GIT_SHA docker-build-push-git-sha
- name: Build and push the git-sha-tagged op-reth image
run: make IMAGE_NAME=$OP_IMAGE_NAME DOCKER_IMAGE_NAME=$OP_DOCKER_IMAGE_NAME GIT_SHA=$GIT_SHA PROFILE=maxperf op-docker-build-push-git-sha
- name: Build and push the git-sha-tagged ${{ matrix.image-name }} image
run: |
CI=true make IMAGE_NAME=${{ matrix.image-name }} DOCKER_IMAGE_NAME=${{ matrix.docker_image_name }} GIT_SHA=$GIT_SHA PROFILE=maxperf ${{ matrix.make_target }}
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,17 @@ define docker_build_push
mkdir -p $(BIN_DIR)/arm64
cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/reth $(BIN_DIR)/arm64/reth

# Conditionally apply cache flags only in CI
DOCKER_BUILD_CACHE_FLAGS :=
ifdef CI
DOCKER_BUILD_CACHE_FLAGS := --cache-from=type=gha --cache-to=type=gha,mode=max
endif

docker buildx build --file ./Dockerfile.cross . \
--platform linux/amd64,linux/arm64 \
--tag $(DOCKER_IMAGE_NAME):$(1) \
--tag $(DOCKER_IMAGE_NAME):$(2) \
$(DOCKER_BUILD_CACHE_FLAGS) \
--provenance=false \
--push
endef
Expand Down Expand Up @@ -286,10 +293,17 @@ define op_docker_build_push
mkdir -p $(BIN_DIR)/arm64
cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/op-reth $(BIN_DIR)/arm64/op-reth

# Conditionally apply cache flags only in CI
DOCKER_BUILD_CACHE_FLAGS :=
ifdef CI
DOCKER_BUILD_CACHE_FLAGS := --cache-from=type=gha --cache-to=type=gha,mode=max
endif

docker buildx build --file ./DockerfileOp.cross . \
--platform linux/amd64,linux/arm64 \
--tag $(DOCKER_IMAGE_NAME):$(1) \
--tag $(DOCKER_IMAGE_NAME):$(2) \
$(DOCKER_BUILD_CACHE_FLAGS) \
--provenance=false \
--push
endef
Expand Down

0 comments on commit a21702e

Please sign in to comment.