diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8c37cb2b0..413437e7e 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,7 @@ name: "Push docker image to GAR" on: push: - branches: [main] + branches: [ main ] tags: - "v*" @@ -40,9 +40,31 @@ jobs: 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 }} diff --git a/Dockerfile b/Dockerfile index 7e27763b2..6ec91299f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,8 @@ RUN apk update && apk add --no-cache --update gcc musl-dev linux-headers git mak WORKDIR /taiko-client COPY . . -RUN make build +RUN --mount=type=cache,target=/root/.cache/go-build,sharing=locked \ + make build FROM alpine:latest