Created
November 28, 2017 00:26
-
-
Save pbnj/d0d03b4e0bd04cae30043a0e4c257e2d to your computer and use it in GitHub Desktop.
Building Go binaries for bare OSes (e.g. alpine)
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.9 AS build | |
LABEL maintainer "Peter Benjamin" | |
WORKDIR /go/src/github.com/petermbenjamin/go-hello-world | |
COPY . . | |
RUN go get -u -v github.com/golang/dep/cmd/dep \ | |
&& dep init \ | |
&& CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o hello-world . | |
FROM alpine | |
COPY --from=build /go/src/github.com/petermbenjamin/go-hello-world/hello-world /usr/bin/hello-world | |
ENTRYPOINT [ "/usr/bin/hello-world" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment