Skip to content

Instantly share code, notes, and snippets.

@mishudark
Created May 12, 2017 20:49
Show Gist options
  • Save mishudark/9e3377ce1917db77a08b36bdbbeda21b to your computer and use it in GitHub Desktop.
Save mishudark/9e3377ce1917db77a08b36bdbbeda21b to your computer and use it in GitHub Desktop.
Go multistage static linked
FROM golang:alpine
WORKDIR /go/src/github.com/mishudark/hello
RUN mkdir -p cmd/hello
COPY main.go cmd/hello/
RUN CGO_ENABLED=0 GOOS=linux go install -ldflags "-s" -a -installsuffix cgo ./cmd/...
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=0 /go/bin/hello .
RUN ./hello
CMD ["./hello"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment