File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,17 @@ var dockerfileTemplate = `# Build the manager binary
40
40
FROM golang:1.12.5 as builder
41
41
42
42
WORKDIR /workspace
43
- # Copy the go source
44
- COPY main.go main.go
45
- COPY api/ api/
46
- COPY controllers/ controllers/
47
43
# Copy the Go Modules manifests
48
44
COPY go.mod go.mod
49
45
COPY go.sum go.sum
46
+ # cache deps before building and copying source so that we don't need to re-download as much
47
+ # and so that source changes don't invalidate our downloaded layer
48
+ RUN go mod download
50
49
50
+ # Copy the go source
51
+ COPY main.go main.go
52
+ COPY api/ api/
53
+ COPY controllers/ controllers/
51
54
52
55
# Build
53
56
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
Original file line number Diff line number Diff line change 2
2
FROM golang:1.12.5 as builder
3
3
4
4
WORKDIR /workspace
5
- # Copy the go source
6
- COPY main.go main.go
7
- COPY api/ api/
8
- COPY controllers/ controllers/
9
5
# Copy the Go Modules manifests
10
6
COPY go.mod go.mod
11
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
12
11
12
+ # Copy the go source
13
+ COPY main.go main.go
14
+ COPY api/ api/
15
+ COPY controllers/ controllers/
13
16
14
17
# Build
15
18
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
You can’t perform that action at this time.
0 commit comments