User Avatar

Cora Iberkleid 🚒

🌊Kubernetes

2y ago

Developer Advocate at Tanzu by Broadcom focused on Kubernetes and Spring related technologies.

Buildpacks 101, For Dockerfilers
Cora Iberkleid 🚒

An intro to Cloud Native Buildpacks, for people who know Dockerfile.

Decent Dockerfile

You may know more about Dockerfile than I do, but as far as I can tell, this one here is not terrible. I've annotated some of the considerations that went into it.

Would I swear it's good enough for production? That no hacker will crack it? That I'll watch for base image patches and let everyone who copies this file know when I've changed it?

Heck no. Not today, not tomorrow, not ever. And that's a red flag.

Buildpacks Basics

Consider the following command:

pack build my-first-cnb-img --builder paketobuildpacks/builder:tiny

  • pack - The "platform." In this case a CLI for an experience similar to docker build...

  • builder - The "builder." An OCI image that contains everything else you need, including:

    • base images - As in a 2-stage Dockerfile (lines 1 and 11), your code will be processed on the builder and then the layers will be exported to a minimal run image.

    • buildpacks - The logic to process code into layers. Like 6-9 above, plus security and optimizations and other features, not just for Java, but also other languages.

    • lifecycle - The APIs for the platform to run Buildpacks on your code. It keeps the platforms and buildpacks decoupled, making it easier for the ecosystem to grow.

Reading Between the Lines

Without any effort and without taking on any responsibility to guarantee or maintain Dockerfiles for yourself or others, you can take advantage of a mature and sophisticated engine for producing secure, efficient, and well-organized OCI images, and you can be sure all applications using this process are accessing the same central, updated builders.

The Tip of The Iceberg

This is just the beginning! Keep an eye out for future posts where I'll dive into other benefits. If you can't wait, try the command pack help and play around with some of the options, including inspect, sbom, and rebase.