Skip to content

Instantly share code, notes, and snippets.

@wwerner
Last active March 27, 2024 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wwerner/43dc05e9a77992da49f74f4f5b5cc1ac to your computer and use it in GitHub Desktop.
Save wwerner/43dc05e9a77992da49f74f4f5b5cc1ac to your computer and use it in GitHub Desktop.
Example multi stage docker file for go builds
FROM golang:1.11.2 as build-image
WORKDIR /go/src
RUN go get -d -v golang.org/x/net/html
COPY app.go .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app app.go
FROM alpine:latest
RUN apk --no-cache add ca-certificates
WORKDIR /root/
COPY --from=build-image /go/src/app .
CMD ["./app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment