Skip to content

Instantly share code, notes, and snippets.

@allanfreitas
Forked from PurpleBooth/Dockerfile
Created July 11, 2018 00:01
Show Gist options
  • Save allanfreitas/55549c2b33b46f57a62e5be715717bbf to your computer and use it in GitHub Desktop.
Save allanfreitas/55549c2b33b46f57a62e5be715717bbf to your computer and use it in GitHub Desktop.
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
RUN mkdir -p /go/src/github.com/purplebooth/example
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment