4 ms·
For image size, it doesn't matter. It does matter for build time. Specifically, multi-stage builds let you get better caching and therefore faster rebuilds, si
by itamarst 6y ago
For image size, it doesn't matter. It does matter for build time.
Specifically, multi-stage builds let you get better caching and therefore faster rebuilds, since you can cache the pre-installed gcc etc. layer, while still getting the small image.
So if you have a human being waiting on frequent Docker build results, yes, multi-stage is better.
In this case, the builds are automated, no one waits for them, so it doesn't really matter (except for burning some extra CPU cycles).
- claytonjy 6y agoThat makes sense, thank you. Is there no downside to multi-stage? Even aside from caching behavior I prefer multi-stage builds, as I'd much rather read & maintain a bunch of RUN lines which do one specific thing, rather than dozens joined with &&.
- itamarst 6y agoThere isn't too much of a downside, except that you need to be a little more careful in your CI, otherwise you can end up rebuilding from scratch each time, thus losing the benefit of faster builds. See here for why and how to fix it: https://pythonspeed.com/articles/faster-multi-stage-builds/ https://pythonspeed.com/articles/faster-multi-stage-builds/