Add example Dockerfile (#18427)

* Add example Dockerfile

* Align with action

* Update cache.md
This commit is contained in:
Matthias Gubler 2023-10-24 07:44:08 -06:00 committed by GitHub
parent 78025e73e4
commit a0831e4d1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -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