Skip to content

Commit

Permalink
dockerfile: make go dependency caching effective
Browse files Browse the repository at this point in the history
Signed-off-by: Michal Minář <[email protected]>
  • Loading branch information
Michal Minář committed Jun 27, 2022
1 parent 35929b3 commit 8ed2fd3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
!go.mod
!go.sum
!index.html
# ignore local GOPATH=$(pwd)/.go/
.go/
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
FROM golang:1.17.3 as builder

WORKDIR /workspace
COPY . .
COPY go.mod 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 . .

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o metrics-exporter .
Expand Down

0 comments on commit 8ed2fd3

Please sign in to comment.