File tree Expand file tree Collapse file tree 2 files changed +24
-16
lines changed Expand file tree Collapse file tree 2 files changed +24
-16
lines changed Original file line number Diff line number Diff line change @@ -37,21 +37,25 @@ func (c *Dockerfile) GetInput() (input.Input, error) {
37
37
}
38
38
39
39
var dockerfileTemplate = `# Build the manager binary
40
- FROM golang:1.10.3 as builder
40
+ FROM golang:1.12.5 as builder
41
41
42
- # Copy in the go src
43
- WORKDIR /go/src/{{ .Repo }}
44
- COPY vendor/ vendor/
42
+ WORKDIR /workspace
43
+ # Copy the go source
45
44
COPY main.go main.go
46
45
COPY api/ api/
47
46
COPY controllers/ controllers/
47
+ # Copy the Go Modules manifests
48
+ COPY go.mod go.mod
49
+ COPY go.sum go.sum
50
+
48
51
49
52
# Build
50
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager {{ .Repo }}/
53
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
51
54
52
- # Copy the controller-manager into a thin image
53
- FROM ubuntu:latest
55
+ # Use distroless as minimal base image to package the manager binary
56
+ # Refer to https://github.com/GoogleContainerTools/distroless for more details
57
+ FROM gcr.io/distroless/base
54
58
WORKDIR /
55
- COPY --from=builder /go/src/{{ .Repo }} /manager .
59
+ COPY --from=builder /workspace /manager .
56
60
ENTRYPOINT ["/manager"]
57
61
`
Original file line number Diff line number Diff line change 1
1
# Build the manager binary
2
- FROM golang:1.10.3 as builder
2
+ FROM golang:1.12.5 as builder
3
3
4
- # Copy in the go src
5
- WORKDIR /go/src/sigs.k8s.io/kubebuilder/testdata/project_v2
6
- COPY vendor/ vendor/
4
+ WORKDIR /workspace
5
+ # Copy the go source
7
6
COPY main.go main.go
8
7
COPY api/ api/
9
8
COPY controllers/ controllers/
9
+ # Copy the Go Modules manifests
10
+ COPY go.mod go.mod
11
+ COPY go.sum go.sum
12
+
10
13
11
14
# Build
12
- RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager sigs.k8s.io/kubebuilder/testdata/project_v2/
15
+ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
13
16
14
- # Copy the controller-manager into a thin image
15
- FROM ubuntu:latest
17
+ # Use distroless as minimal base image to package the manager binary
18
+ # Refer to https://github.com/GoogleContainerTools/distroless for more details
19
+ FROM gcr.io/distroless/base
16
20
WORKDIR /
17
- COPY --from=builder /go/src/sigs.k8s.io/kubebuilder/testdata/project_v2 /manager .
21
+ COPY --from=builder /workspace /manager .
18
22
ENTRYPOINT ["/manager" ]
You can’t perform that action at this time.
0 commit comments