Live data from Hacker News

Buildpacks vs. Dockerfiles

technology.doximity.com

21–30 of 91 posts

Re: Buildpacks vs. Dockerfiles

#21
Building Docker images is a tricky design problem, as with many ops tasks. The problem is due to 3 issues:

1. A Docker image is the intersection of literally 50 years of technology, starting from Unix in the 1970s, none of which are perfect. Decisions from back then still have an impact, e.g. you need to get signal handling right if you want shutdown to work (https://hynek.me/articles/docker-signals/).

2. Getting it right is all about _details_. Lots and lots of details, all of which need to be correct. Signal handling, where logs go, security updates, on and on.

3. Every organization does things slightly differently.

So there are multiple approaches:

== Build an abstracted tool ==

A tool will support certain conventions and ways of doing things... but as soon as you want to diverge too much you'll start having issues, because it only supports its particular way of doing things.

Pros: Easy for users.

Cons: Only so long as they don't want something the tool can't handle.

The problem is that it's quite difficult to build a tool that works for _all_ organizations. If you've built a custom buildpack for your company, you've built a custom tool, which a pretty good solution, but still every organization has to build their own tool.

== Build a configuration language ==

In order to support all the edge cases, you build a configuration language... and pretty soon it's super complicated because there are so many different things people want to do. In fact, you end up with something with complexity of Dockerfile. Probably can do better than "it's a shell script", but it's not going to be simple, and you're back to "users have to figure out all the details on their own".

Pros: Flexible.

Cons: You still need to get details right.

== Template ==

Here you do something tool-like: it knows about conventions, is customized for specific common use cases. But, you copy the code into you application repository, so you can then customize anything that doesn't fit.

I have built a template for production Docker packaging of Python applications (https://pythonspeed.com/products/pythoncontainer/) and this is the approach I went with.

Pros: Works most of the time out of the box, can be customized when it doesn't.

Cons: Hard to update if you're ending up doing too many per-application customizations.

---

Obviously this is a simplification, and these options tend to merge at the edges. But fundamentally it's a hard design space and there is no magic bullet, just tradeoffs. Longer version, presented slightly differently: https://pythonspeed.com/articles/developing-tools-for-ops/

Re: Buildpacks vs. Dockerfiles

#22
post #20

I’m sure it’s usually just a case of “thinking while typing”, but I find it surprising how often articles about Docker stuff get some basic details a bit wrong. In the very first code example there is a RUN instruction where the author probably meant to have a CMD instruction, and they talk about BuildKit and build cache optimisation even though that was always something to think about, way before BuildKit was a thin…

Might have been an intentional mistake ? It fits the arguments pro build-packs.

Re: Buildpacks vs. Dockerfiles

#23
post #22
post #20

I’m sure it’s usually just a case of “thinking while typing”, but I find it surprising how often articles about Docker stuff get some basic details a bit wrong. In the very first code example there is a RUN instruction where the author probably meant to have a CMD instruction, and they talk about BuildKit and build cache optimisation even though that was always something to think about, way before BuildKit was a thin…

Might have been an intentional mistake ? It fits the arguments pro build-packs.

The RUN? I thought about that but I don’t see how that would work. Or is the argument that Dockerfiles are just too hard?

(An argument I’m not unsympathetic to)

Re: Buildpacks vs. Dockerfiles

#24
post #8

What are some hosting providers providing build packages support? Google and Heroku were mentioned in the article. I've also had a good experience with self-managed Dokku deployment. Are there any managed service providers that support buildpack deployment?

https://render.com is easy to use and very promising

Re: Buildpacks vs. Dockerfiles

#26

During the last 3 years I've had the pleasure of using Bazel's rules_docker to generate all my container images ( https://github.com/bazelbuild/rules_docker ). In a nutshell, rules_docker is a set of build rules for the Bazel build system ( https://bazel.build ). What's pretty nice about these rules is that they don't rely on a Docker daemon. They are rules that directly construct image tarballs that you can either l…

We've used Google Jib for Docker for the same reasons.

It also means we don't have to think about the layout of our images. I know that if we went with Dockerfiles each team would put application code in different directories. There would be no consistency. Jib hides that away from us.

Re: Buildpacks vs. Dockerfiles

#27
post #13

During the last 3 years I've had the pleasure of using Bazel's rules_docker to generate all my container images ( https://github.com/bazelbuild/rules_docker ). In a nutshell, rules_docker is a set of build rules for the Bazel build system ( https://bazel.build ). What's pretty nice about these rules is that they don't rely on a Docker daemon. They are rules that directly construct image tarballs that you can either l…

Sounds similar to podman [1] which also doesn't require a daemon (though you can run it with one if you like). [1] https://podman.io/getting-started/ Back to the original article, I prefer dockerfile-based builds as it allows me to run my own tests easily on the image locally before uploading. Can this be done with buildkits?

There is ongoing work with Buildpacks (specifically `pack`, the project CLI), to integrate better with podman, and enable a daemon-less workflow.

We most often build it with the local docker daemon (though you can with a remote docker daemon), test it, and then publish the image.

Re: Buildpacks vs. Dockerfiles

#28
post #8

What are some hosting providers providing build packages support? Google and Heroku were mentioned in the article. I've also had a good experience with self-managed Dokku deployment. Are there any managed service providers that support buildpack deployment?

A list of adopters (many of which are hosting providers) is here: https://github.com/buildpacks/community/blob/main/ADOPTERS.m...

Re: Buildpacks vs. Dockerfiles

#29

During the last 3 years I've had the pleasure of using Bazel's rules_docker to generate all my container images ( https://github.com/bazelbuild/rules_docker ). In a nutshell, rules_docker is a set of build rules for the Bazel build system ( https://bazel.build ). What's pretty nice about these rules is that they don't rely on a Docker daemon. They are rules that directly construct image tarballs that you can either l…

I use Nix to do something similar: https://gitlab.com/kevincox/feed-test/-/blob/8b217add5fc11bb...

Re: Buildpacks vs. Dockerfiles

#30
Am I missing something? The author seems like they just don't want devs to maintain their build, so why not "just use someone else's fit-for-purpose container image"? Whether that someone else is an external entity equivalent to buildpack maintainers, or your devops team, which should know Docker.
Post reply on HN