File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed
cmd/training-operator.v2alpha1 Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 1
1
# Build the manager binary
2
- FROM golang:1.22 as builder
2
+ FROM golang:1.22 AS builder
3
3
4
4
WORKDIR /workspace
5
- # Copy the Go Modules manifests
6
- COPY go.mod go.mod
7
- COPY go.sum go.sum
8
- # cache deps before building and copying source so that we don't need to re-download as much
9
- # and so that source changes don't invalidate our downloaded layer
10
- RUN go mod download
11
-
12
- # Copy the go source
13
- COPY . .
14
5
15
6
# Build
16
- RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager cmd/training-operator.v2alpha1/main.go
7
+ RUN --mount=type=cache,target=/go/pkg/mod/,sharing=locked \
8
+ --mount=type=bind,source=go.sum,target=go.sum \
9
+ --mount=type=bind,source=go.mod,target=go.mod \
10
+ go mod download
11
+ RUN --mount=type=cache,target=/go/pkg/mod/ \
12
+ --mount=type=bind,target=. \
13
+ CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o /bin/manager cmd/training-operator.v2alpha1/main.go
17
14
18
15
# Use distroless as minimal base image to package the manager binary
19
16
# Refer to https://github.com/GoogleContainerTools/distroless for more details
20
17
FROM gcr.io/distroless/static:nonroot
21
18
WORKDIR /
22
- COPY --from=builder /workspace /manager .
19
+ COPY --from=builder /bin /manager .
23
20
ENTRYPOINT ["/manager" ]
You can’t perform that action at this time.
0 commit comments