mirror of https://github.com/docker/docs.git
Add example Dockerfile (#18427)
* Add example Dockerfile * Align with action * Update cache.md
This commit is contained in:
parent
78025e73e4
commit
a0831e4d1e
|
|
@ -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.
|
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
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
on: push
|
on: push
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue