Skip to content

Instantly share code, notes, and snippets.

@JulienBreux
Last active May 14, 2022 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulienBreux/c463171d6fc91565705b4f791d88f137 to your computer and use it in GitHub Desktop.
Save JulienBreux/c463171d6fc91565705b4f791d88f137 to your computer and use it in GitHub Desktop.
Multi-stage builds example
# @see https://github.com/JulienBreux/tuto-go-docker-ms
FROM golang:1.9-alpine as builder
WORKDIR /go/src/github.com/JulienBreux/tuto-go-docker-ms/
RUN apk --update add ca-certificates
# RUN go get -d -v golang.org/x/net/html
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
FROM scratch
ENV PATH=/bin
WORKDIR /root/
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /go/src/github.com/JulienBreux/tuto-go-docker-ms/app .
CMD ["./app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment