Skip to content

Commit

Permalink
Merge pull request #770 from mengqiy/cachegomod
Browse files Browse the repository at this point in the history
✨ cache go module cache in docker
  • Loading branch information
k8s-ci-robot authored Jun 7, 2019
2 parents 9fa919d + fe027da commit deb65f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions pkg/scaffold/v2/dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ var dockerfileTemplate = `# Build the manager binary
FROM golang:1.12.5 as builder
WORKDIR /workspace
# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download
# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
Expand Down
11 changes: 7 additions & 4 deletions testdata/project-v2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
FROM golang:1.12.5 as builder

WORKDIR /workspace
# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
# and so that source changes don't invalidate our downloaded layer
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
Expand Down

0 comments on commit deb65f3

Please sign in to comment.