chore(ci): introduce docker build cache (#234)

This commit is contained in:
maskpp 2024-05-07 20:05:20 +08:00 committed by GitHub
parent 68308e3781
commit fdb980ab06
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 26 additions and 2 deletions

View file

@ -2,7 +2,7 @@ name: "Push docker image to GAR"
on:
push:
branches: [taiko]
branches: [ taiko ]
tags:
- "v*"
@ -38,9 +38,32 @@ jobs:
type=ref,event=pr
type=ref,event=tag
type=sha
- name: Cache Go build
uses: actions/cache@v4
with:
enableCrossOsArchive: true
path: |
go-build-platforms
key: ${{ runner.os }}-go_build-platforms
restore-keys: |
${{ runner.os }}-go_build-platforms
- name: Inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"go-build-platforms": "/root/.cache/go-build"
}
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}

View file

@ -14,7 +14,8 @@ COPY go.sum /go-ethereum/
RUN cd /go-ethereum && go mod download
ADD . /go-ethereum
RUN cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
RUN --mount=type=cache,target=/root/.cache/go-build,sharing=locked \
cd /go-ethereum && go run build/ci.go install -static ./cmd/geth
# Pull Geth into a second stage deploy alpine container
FROM alpine:latest