File tree Expand file tree Collapse file tree 4 files changed +14
-9
lines changed
extensions/extensions-sdk/build Expand file tree Collapse file tree 4 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,7 @@ tool you're using. Here are a few examples:
225
225
226
226
``` dockerfile
227
227
RUN --mount=type=cache,target=/go/pkg/mod \
228
+ --mount=type=cache,target=/root/.cache/go-build \
228
229
go build -o /app/hello
229
230
```
230
231
Original file line number Diff line number Diff line change @@ -197,13 +197,16 @@ Example Dockerfile in `build/package/Dockerfile`
197
197
FROM golang:1.21.1-alpine as base-build
198
198
199
199
WORKDIR /build
200
- RUN go env -w GOMODCACHE=/root/.cache/go-build
201
200
202
- COPY go.mod go.sum ./
203
- RUN --mount=type=cache,target=/root/.cache/go-build go mod download
201
+ RUN --mount=type=cache,target=/go/pkg/mod \
202
+ --mount=type=bind,source=go.mod,target=go.mod \
203
+ --mount=type=bind,source=go.sum,target=go.sum \
204
+ go mod download
204
205
205
- COPY ./src ./
206
- RUN --mount=type=cache,target=/root/.cache/go-build go build -o /bin/app /build/src
206
+ RUN --mount=type=cache,target=/go/pkg/mod \
207
+ --mount=type=cache,target=/root/.cache/go-build \
208
+ --mount=type=bind,target=. \
209
+ go build -o /bin/app /build/src
207
210
...
208
211
` ` `
209
212
Original file line number Diff line number Diff line change @@ -190,13 +190,13 @@ FROM node:17.7-alpine3.14 AS client-builder
190
190
FROM golang:1.17-alpine AS builder
191
191
ENV CGO_ENABLED=0
192
192
WORKDIR /backend
193
- COPY vm/go.* .
194
193
RUN --mount=type=cache,target=/go/pkg/mod \
195
- --mount=type=cache,target=/root/.cache/go-build \
194
+ --mount=type=bind,source=vm/go.mod,target=go.mod \
195
+ --mount=type=bind,source=vm/go.sum,target=go.sum \
196
196
go mod download
197
- COPY vm/. .
198
197
RUN --mount=type=cache,target=/go/pkg/mod \
199
198
--mount=type=cache,target=/root/.cache/go-build \
199
+ --mount=type=bind,source=vm/.,target=. \
200
200
go build -trimpath -ldflags="-s -w" -o bin/service
201
201
202
202
FROM alpine:3.15
Original file line number Diff line number Diff line change @@ -8,8 +8,9 @@ FROM golang:${GO_VERSION}-alpine AS base
8
8
RUN apk add --no-cache openssl
9
9
ENV CGO_ENABLED=0
10
10
WORKDIR /src
11
- COPY go.mod go.sum ./
12
11
RUN --mount=type=cache,target=/go/pkg/mod \
12
+ --mount=type=bind,source=go.mod,target=go.mod \
13
+ --mount=type=bind,source=go.sum,target=go.sum \
13
14
go mod download
14
15
15
16
FROM base AS releaser
You can’t perform that action at this time.
0 commit comments