Skip to content

Instantly share code, notes, and snippets.

@rob-sokolowski
Created July 29, 2024 23:33
Show Gist options
  • Save rob-sokolowski/ff6481548fdd52ce454edc94f8df7577 to your computer and use it in GitHub Desktop.
Save rob-sokolowski/ff6481548fdd52ce454edc94f8df7577 to your computer and use it in GitHub Desktop.
FROM golang:1.22 as build
USER root
WORKDIR /go/src/app
COPY . .
RUN go mod download
RUN CGO_ENABLED=1 go build -v -o /app .
# Now copy it into our base image.
#
# Note: I moved off the official "distroless" image, due to this issue: https://github.com/GoogleContainerTools/distroless/issues/1342
# I have no clue of the differences, but this works *shrug*
FROM cgr.dev/chainguard/glibc-dynamic
USER root
WORKDIR /
COPY --from=build /app /app
COPY --from=build /go/src/app/.private /private
CMD ["/app"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment