Skip to content

Commit

Permalink
ci/cache docker layers (#543)
Browse files Browse the repository at this point in the history
* chore: use the same COPY for go.mod and go.sum

* chore: update docker actions to latest versions

* build: optimize Go build process with caching

* test: trigger build on PR to test

* test: dummy change on go code to test cache

* test: run go mod -u=patch to measure how docker holds

* Revert "test: dummy change on go codeto confirm that cache still works"

* Revert "test: run go mod -u=patch to measure how docker holds"

This reverts commit 92df7a5.

* Revert "test: trigger build on PR to test"

This reverts commit 0d0d452.
  • Loading branch information
paulopontesm authored Oct 19, 2023
1 parent c52858a commit c9d96e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
23 changes: 18 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ jobs:
echo ${{ env.RELEASE_VERSION }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
uses: docker/setup-qemu-action@v3

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

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: flashbots/mev-boost-relay
tags: |
Expand All @@ -41,13 +41,24 @@ jobs:
type=raw,value=latest,enable=${{ !contains(env.RELEASE_VERSION, '-') }}
- name: Login to DockerHub
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Go Build Cache for Docker
uses: actions/cache@v3
with:
path: go-build-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}

- name: inject go-build-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-source: go-build-cache

- name: Build and push
uses: docker/build-push-action@v3
uses: docker/build-push-action@v5
with:
context: .
push: true
Expand All @@ -56,6 +67,8 @@ jobs:
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

github-release:
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ ARG VERSION
WORKDIR /build

# Cache for the modules
COPY go.mod ./
COPY go.sum ./
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/root/.cache/go-build go mod download

# Now adding all the code and start building
Expand Down

0 comments on commit c9d96e1

Please sign in to comment.