Skip to content

Instantly share code, notes, and snippets.

@dirkarnez
Forked from PurpleBooth/Dockerfile
Created February 19, 2020 14:44
Show Gist options
  • Select an option

  • Save dirkarnez/ca9a762d18e6da7b22b09d23f1b18720 to your computer and use it in GitHub Desktop.

Select an option

Save dirkarnez/ca9a762d18e6da7b22b09d23f1b18720 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
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