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 7812c22
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
25 changes: 17 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,12 +20,26 @@ 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
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: ${{ matrix.image-name }}
- uses: taiki-e/install-action@cross
- name: Log in to Docker
run: |
Expand All @@ -38,7 +48,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 }}
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ FULL_DB_TOOLS_DIR := $(shell pwd)/$(DB_TOOLS_DIR)/

CARGO_TARGET_DIR ?= target

DOCKER_BUILD_CACHE_FLAGS :=
ifdef CI
DOCKER_BUILD_CACHE_FLAGS := --cache-from=type=gha --cache-to=type=gha,mode=max
endif

# List of features to use when building. Can be overridden via the environment.
# No jemalloc on Windows
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -238,6 +243,7 @@ define docker_build_push
--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 @@ -290,6 +296,7 @@ define op_docker_build_push
--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 7812c22

Please sign in to comment.