Hacker News new | ask | show | jobs
by qbasic_forever 1564 days ago
If you care about image size you need to switch to a distroless image base. It's incredibly easy nowadays with multi-stage builds. IMHO people use alpine not because they seek it out but because they're reading old guides and advice that hasn't been updated with the times.

Blindly switching to alpine to save space is opening yourself up to exactly these sorts of musl-libc quirks and issues--you better have solid test coverage and a plan to make sure there aren't unexpected edge cases.

2 comments

I would suggest to just use a small number of base images. The total size of all layerse is irrelevant in most cases if it's a small layer on top of something common for you = cached.
There are a lot of tools that simply can't run distroless and adding in all the requirements is often tedious with little reward.
What are some of the tools that can't run on distroless?
Anything that relies on system libraries. This works fine for most Go apps, but can have unexpected results if you don't compile the app correctly to use Go networking and what not.
I see. Regarding Go, how would forget to import the Go net and http packages for your app? I would think your compilation itself would fail to begin with. Or are you referring to something else?
In my time building Go apps in the past, you'd need to specify the netgo tag and others. Not sure if this is necessary anymore, but I can think of a few Go packages that require CGO and what not that will not work using a scratch image.