Skip to content

Instantly share code, notes, and snippets.

@kylejeske
Created April 24, 2019 17:51
Show Gist options
  • Save kylejeske/7688e65981f914fb33a339a1bae65559 to your computer and use it in GitHub Desktop.
Save kylejeske/7688e65981f914fb33a339a1bae65559 to your computer and use it in GitHub Desktop.
Example of GoLang min build in Multi-Stage Dockerfile
FROM golang:alpine AS base-build
RUN apk update && apk add --no-cache git
WORKDIR $GOPATH/src/mypackage/myapp/
COPY . .
RUN go get -d -v
RUN go build -o /go/bin/hello
## using COPY
FROM scratch
## COPY --from=base-builder /go/bin/hello /go/bin/hello
## OR
COPY --from=$0 /go/bin/hello /go/bin/hello
ENTRYPOINT ["/go/bin/hello"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment