Go's Dockerfile journey

Creeping complexity in packaging Go with Docker

Published: Friday, Aug 11, 2023 Last modified: Friday, Dec 8, 2023

Once upon a time all you needed to Dockerize an app was the 2016 deprecated onbuild:

FROM golang:onbuild

Then we went multistage:

FROM alpine:latest
RUN apk --no-cache add ca-certificates
COPY --from=builder /go/bin/app /app

Building a #golang container image for production

One of the many reasons I love GO is how easy it is to build and containerise. However, it's also important to ensure your production application has the smallest attack surface possible, is portable, and small in size.

Let's… pic.twitter.com/WcFOttzMRW

— Matt Boyle (@MattJamesBoyle) August 10, 2023

Now distroless is said to be 50% smaller than Alpine, since it doesn’t have a shell, though distroless has:



Then often you need curl to run health checks.