-
-
Save camilb/16f7202e4c4929c8831d1e41490e2def to your computer and use it in GitHub Desktop.
production go dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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