Skip to content
← Back to Blog

The Anyport Team

Buildpack or Dockerfile: which should build your app

One gives you a maintained base image you never think about. The other gives you exact control. Where each one earns its place, and the case where only one works.

If you deploy from source, something has to turn a repository into a container image. There are two established ways to do that, and the choice is less about taste than about which set of problems you would rather own.

The Dockerfile

A Dockerfile is a script. You state the base image, the system packages, how dependencies are installed, what gets copied, and what runs. Nothing is inferred, which is the whole appeal: when the build does something surprising, the reason is in a file you can read.

The cost is that you now maintain it. The base image you pinned in March accumulates vulnerabilities by August, and nothing reminds you. Multi-stage builds and layer ordering are real skills, and a badly ordered Dockerfile turns a thirty-second build into a four-minute one. Every service in the company ends up with a slightly different variant of the same file, each with its own quirk.

The buildpack

A buildpack inverts it. Instead of describing the build, you let a set of them inspect the repository and work it out: this has a lockfile, so it is a Node project; here is how Node projects get built; here is the runtime image to put the result on.

What you get is a build nobody has to maintain and a base image that is somebody else's job to patch. When a vulnerability lands in the runtime, rebuilding picks up the fix without an edit. For an ordinary web service in a mainstream language, this is a genuinely good trade, and it removes a file most teams never wanted to write.

What you give up is the ability to say exactly what you meant. Anything unusual — a system library, an odd runtime, a compilation step the detection does not recognise — either has a documented escape hatch or does not fit.

The case that decides itself

A built single-page application is static files. There is no server process for a buildpack to detect and start, so the buildpack path has nothing to run even when the build itself succeeds. The answer there is a Dockerfile: build the assets, copy them into an image with a small static web server, and serve them.

Worth knowing rather than discovering, because the failure is not obvious. The build works, and then there is no process.

How this lands in Anyport

Both paths run on your own cluster, from a repository you have connected. That has one consequence worth naming: builds are never billed by the minute here, because the machine doing the work is already yours. There is no incentive on our side for your builds to be slow, and no queue you are waiting in behind other customers.

If you already build images in your own CI, you can skip the question entirely and point Anyport at the resulting image instead. You keep your pipeline; the rollout, the revisions and the rollback are handled either way.

One last detail if you go the Dockerfile route and finish on scratch or a distroless base: that image has no shell, so there is nothing to attach a terminal to. Anyport notices and offers to run a debug container alongside it instead, which is usually what you wanted at that moment anyway.