About

Tool No. 63 of Pikkola

A Dockerfile is a short file with a long reach. The order of its lines decides how long a rebuild takes, how much of the compiler ends up in production, and which user the process runs as. This page writes that order for a stack you pick, and reads an existing file to say where the order was broken.

What it does

The three benches

The Dockerfile bench is a function per stack. Each one knows the base image, the manifest files, the install command and the path the process starts from, and each one has a single-stage and a multi-stage shape. The switches do not edit the text afterwards; they are arguments to the function, so a file is never assembled from fragments that disagree with each other.

The compose bench is the same idea around a service graph. The app is always the service that builds from the file next door. PostgreSQL, Redis and the proxy are added in a fixed order, because the order in a compose file is also the order a reader meets it. A health check is copied into the compose file for the app in the form the runtime can actually run: a node one-liner for Node, an urllib call for Python, wget for Alpine, curl where curl was installed.

The audit bench joins continuation lines into one instruction before reading, because Docker does. A RUN that installs packages across four lines is one instruction with one line number, and a COPY that appears before it is a cache problem no matter how the newlines fall.

Why the order is what it is

Every instruction is a cache key over the files it touches. COPY package.json and the install that follows are stable as long as the lockfile is, so a source edit stops at the next instruction instead of running everything again. That is the whole reason the manifest is copied first, and the whole reason the audit treats COPY . . before the install as a finding rather than a style note.

The last stage holds only what runs. For Node that is the production dependency tree and the build output; for Go a static binary on Alpine; for Rust the target binary on Debian with the CA certificates it needs. The compiler, the headers and the source stay in the stage that needed them, and an image that is 80 MB instead of 900 MB is a smaller thing to patch.

Where the limits are

Why it is free

Pikkola builds small tools with one job each and keeps them free, with no account and no lock on the result. A static page that works in the browser costs almost nothing to serve, so there is no reason to charge for it or to watch who uses it.

Contact

A Dockerfile this page writes in a way your stack cannot use, a finding that is wrong, a Korean or Japanese sentence that reads badly: [email protected]. The file itself and the line you disagree with are the most useful things to send.

Back to the studio