Skip to content

Commit 9922dab

Browse files
committed
reduce plural container image size
Signed-off-by: DavidSpek <[email protected]>
1 parent b822ee0 commit 9922dab

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

Dockerfile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
1-
FROM gcr.io/pluralsh/golang:alpine AS cmd
1+
FROM gcr.io/pluralsh/golang:1.18.2-alpine3.15 AS builder
22

3-
RUN apk update && apk add --no-cache git build-base
3+
WORKDIR /workspace
4+
# Copy the Go Modules manifests
5+
COPY go.mod go.mod
6+
COPY go.sum go.sum
7+
# cache deps before building and copying source so that we don't need to re-download as much
8+
# and so that source changes don't invalidate our downloaded layer
9+
RUN go mod download
10+
11+
# Copy the go source
12+
COPY cmd/ cmd/
13+
COPY pkg/ pkg/
414

5-
WORKDIR $GOPATH/src/plural/
6-
COPY . .
7-
RUN go build -o /go/bin/plural -ldflags '-s -w' ./cmd/plural/
8-
RUN /go/bin/plural --help
15+
# Build
16+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o plural -ldflags '-s -w' ./cmd/plural/
17+
18+
FROM gcr.io/pluralsh/golang:1.18.2-alpine3.15
19+
RUN apk update && apk add --no-cache git build-base
20+
WORKDIR /
21+
COPY --from=builder /workspace/plural /go/bin/
22+
RUN /go/bin/plural --help

0 commit comments

Comments
 (0)