Open Desdemo opened 2 months ago
Same here!
Dockerfile:
ARG go_mod_cache
ARG go_build_cache
ENV GOMODCACHE=$go_mod_cache
ENV GOCACHE=$go_build_cache
RUN --mount=type=cache,target=${GOMODCACHE} \
--mount=type=bind,source=go.sum,target=go.sum \
--mount=type=bind,source=go.mod,target=go.mod \
go mod download
COPY ./ .
RUN --mount=type=cache,target=${GOMODCACHE} \
--mount=type=cache,target=${GOCACHE} \
go build -gcflags="all=-N -l" -tags ent -o /bin/server /src/${service}/cmd/${service}
Worflow file:
- name: Go Mod Cache
id: go-mod-cache
uses: actions/cache@v4
with:
path: go-mod-cache
key: go-mod-cache-${{ hashFiles('go.sum') }}
restore-keys: |
go-mod-cache
- name: Go Build Cache
id: go-build-cache
uses: actions/cache@v4
with:
path: go-build-cache
key: go-build-cache-${{ matrix.service }}-${{ hashFiles(format('{0}/**', matrix.service)) }}
restore-keys: |
go-build-cache-${{ matrix.service }}
- name: inject go-build-cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-map: |
{
"go-mod-cache": "/github/home/go-mod-cache",
"go-build-cache": "/github/home/go-build-cache"
}
skip-extraction: ${{ steps.go-mod-cache.outputs.cache-hit && steps.go-build-cache.outputs.cache-hit }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
push: true
file: ${{ matrix.file }}
target: ${{ matrix.target }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
service=${{ matrix.service }}
CACHEBUST=${{ github.sha }}
go_mod_cache=/github/home/go-mod-cache
go_build_cache=/github/home/go-build-cache
And:
Any update here? I am hitting the same issues @noamcattan described above (with very similar setup) quite often. Rerun usually help, but it is annoying.
dockerfile
git.yml
the log
Error while cleaning cache source directory: Error: EACCES: permission denied, unlink 'go-build-cache/go.opencensus.io@v0.22.5/.gitignore'. Ignoring...
And it takes about the same amount of time to build as it would if we didn't use the cache.
But, my local cache builds very quickly.