Skip to content

Instantly share code, notes, and snippets.

@jackgris
Forked from MatthewJamesBoyle/DOCKERFILE
Created August 10, 2023 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackgris/59ac47175106df0cc02564c5c29ec902 to your computer and use it in GitHub Desktop.
Save jackgris/59ac47175106df0cc02564c5c29ec902 to your computer and use it in GitHub Desktop.
production go dockerfile
FROM golang:1.21.0-bullseye as builder
COPY . /workdir
WORKDIR /workdir
ENV CGO_CPPFLAGS="-D_FORTIFY_SOURCE=2 -fstack-protector-all"
ENV GOFLAGS="-buildmode=pie"
RUN go build -ldflags "-s -w" -trimpath ./cmd/app
FROM gcr.io/distroless/base-debian11:nonroot
COPY --from=builder /workdir/app /bin/app
USER 65534
ENTRYPOINT ["/bin/app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment