Skip to content

Commit db5419c

Browse files
committed
perf: use multistage build to slim down backend container
1 parent 78b095c commit db5419c

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:latest
1+
FROM golang:latest AS builder
22

33
LABEL app="slo-tracker"
44
LABEL maintainer="roshan.aloor@gmail.com"
@@ -8,9 +8,16 @@ LABEL description="slo-tracker : Track your product SLO"
88
WORKDIR /app
99

1010
COPY . .
11-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /app/slo-tracker .
11+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o /app/slo-tracker .
1212

1313

14+
FROM scratch
15+
16+
# we don't need these certs for local development, but we copy in case you want
17+
# to use this image for a production environment
18+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
19+
COPY --from=builder /app/slo-tracker /app/slo-tracker
20+
1421
EXPOSE 8080
1522

16-
CMD /app/slo-tracker
23+
CMD ["/app/slo-tracker"]

0 commit comments

Comments
 (0)