Compares two builds of an image and prints a Markdown table: per-instruction layer size before/after, sorted by change.
$ dfsize diff myapp:main myapp:pr --max-growth-mb 50
**Image size (uncompressed):** 148.2 MB → 862.9 MB (+714.7 MB)
| Instruction | Before | After | Δ |
|---|---:|---:|---:|
| `RUN pip install torch` | — | 700.0 MB | +700.0 MB |
...
dfsize snapshot IMAGE -o main.jsonstores layer sizes (e.g. as a CI artifact frommain);dfsize diff main.json myapp:prcompares against it.--max-growth-mb Nexits 1 if the total grows more than N MB (CI gate).- Sizes are uncompressed layer sizes from
docker history. Compressed (registry) sizes are never mixed in. - Layers are matched by normalized instruction text (difflib alignment, oldest first). That is deliberately simple and has limits (below).
Checked locally here: docker history --no-trunc on BuildKit-built images exposes CreatedBy per layer with # buildkit suffix and
per-layer size, so text matching works for single-stage builds and for the final stage of multi-stage builds; the tests build real images.
Not verified (no web research was done for this repo): current state of container-diff (the brief says archived, last push 2024-03-27),
dive, docker scout compare. Treat the "no existing tool does this" claim from the brief as unverified.
- Only the final stage's layers are visible in
docker history;COPY --fromappears as aCOPYlayer, not as the producing stage. - If the same instruction text occurs twice, alignment is by order; a squashed image (
--squash) has no per-instruction layers. - If a base image changes, its layers show as removed/added build steps of the base (that is real information, but noisy).
action.yml builds the Dockerfile at the PR head and at the base ref and posts the table to the job summary.
(Note: Actions are currently disabled on the author's account, so the Action is untested in CI; the CLI is tested locally.)
pip install -e .[dev] && pytest (the real-build test needs a running Docker daemon and alpine:3.20; skipped otherwise).