Skip to content

Instantly share code, notes, and snippets.

@pbnj
Created November 28, 2017 00:26
Show Gist options
  • Save pbnj/d0d03b4e0bd04cae30043a0e4c257e2d to your computer and use it in GitHub Desktop.
Save pbnj/d0d03b4e0bd04cae30043a0e4c257e2d to your computer and use it in GitHub Desktop.
Building Go binaries for bare OSes (e.g. alpine)
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