Building small Docker images faster

  • I've seen so many devs not know that things like multi stage even exists.

    Multi gigabyte containers everywhere.

  • I always like finding people advocating for older sage knowledge and bringing it forward for new audiences. That said, as someone who wrote a book about Docker and has lived the full container journey I tend to skip the containerized build all together. Docker makes for great packaging. But containerizing ever step of the build process or even just doing it in one big container is a bit extra. Positioning it as a build scripting solution was silly.

  • For go specifically, I find ko-build handy. It builds on the host (leveraging go crosscompilation and taking advantage of caches) and outputs a Docker image.

  • A Bazel option is https://github.com/bazel-contrib/rules_oci

    Doesn’t even need Docker, just writes the image files with a small Python script.

    Can build from scratch, or use the very small Distroless images.

  • For even smaller images that are always deterministic/reproducible with a multi-party signed supply chain, check out https://stagex.tools