Last active
February 8, 2022 20:46
-
-
Save samuelb/92faefb9169e1df79a8b27293aa43822 to your computer and use it in GitHub Desktop.
Build static linked golang programm and put it into an empty docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.17 as builder | |
WORKDIR /go/src/app | |
COPY go.mod . | |
COPY go.sum . | |
RUN go mod download | |
COPY main.go . | |
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-w -s" -o app | |
FROM scratch | |
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt | |
COPY --from=builder /go/src/app/app . | |
CMD ["./app"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment