diff --git a/content/build/ci/github-actions/cache.md b/content/build/ci/github-actions/cache.md index 82e371cc2e..7c16ca1287 100644 --- a/content/build/ci/github-actions/cache.md +++ b/content/build/ci/github-actions/cache.md @@ -145,6 +145,22 @@ cache mount data with your Docker build steps. The following example shows how to use this workaround with a Go project. +Example Dockerfile in `build/package/Dockerfile` +```Dockerfile +FROM golang:1.21.1-alpine as base-build + +WORKDIR /build +RUN go env -w GOMODCACHE=/root/.cache/go-build + +COPY go.mod go.sum ./ +RUN --mount=type=cache,target=/root/.cache/go-build go mod download + +COPY ./src ./ +RUN --mount=type=cache,target=/root/.cache/go-build && go build -o /bin/app /build/src +... +``` + +Example CI action ```yaml name: ci on: push