Skip to content

Commit 37509fc

Browse files
committed
dockerfile for multistage builds using scratch image
1 parent d31ef20 commit 37509fc

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

scratch.dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM golang as builder
2+
3+
WORKDIR /go/github.com/coding-latte/golang-docker-multistage-build-demo
4+
5+
COPY . .
6+
7+
RUN go get .
8+
9+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
10+
11+
# install ca-certificates
12+
#RUN apk --update add ca-certificates
13+
14+
15+
# deployment image
16+
FROM scratch
17+
18+
# RUN apk --no-cache add ca-certificates
19+
20+
LABEL author="Maina Wycliffe"
21+
22+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
23+
24+
WORKDIR /bin/
25+
26+
COPY --from=builder /go/github.com/coding-latte/golang-docker-multistage-build-demo/app .
27+
28+
CMD [ "./app" ]
29+
30+
EXPOSE 8080

0 commit comments

Comments
 (0)