Image size diffs on every pull request

Dev toolWebweekendGitHub ActionsNode.jsNext.js

The idea

Docker images grow one innocent layer at a time: an apt-get install here, a copied node_modules there, and eighteen months later the image is 2.4 GB, cold starts crawl and the registry bill is real. The growth is invisible because image size is never in front of the person causing it; dive proves developers care about layer analysis, but a local TUI requires someone to think to run it, which nobody does during review.

Frontend teams already solved this exact shape of problem with bundle-size bots: put the delta in the PR comment and regressions stop at review time instead of being archaeology later. The wedge is doing the same for images, with the one detail that makes the comment actionable: naming the specific Dockerfile line responsible for the growth, not just the total.

Who pays

The buyer is a backend or platform engineer at a team paying for registry storage and suffering slow deploys, at 9 to 29 dollars a month per org for private repos. Free on public repos drives distribution: the Action spreads through open-source Dockerfiles and the GitHub Marketplace, and the sticky comment itself is the ad every contributor sees.

MVP scope

  • Composite GitHub Action analysing per-layer sizes from the locally built image
  • Baseline comparison against the base branch via registry ref or cached artifact manifest
  • One sticky PR comment with total delta, changed-layer table and worst-offender callout mapped to a Dockerfile line
  • warn-above and fail-above MB thresholds that can fail the check
  • Detection of common smells like uncleaned apt cache and missing multi-stage builds
  • Skip for v1: a hosted dashboard, historical trend graphs, multi-image matrices, automated Dockerfile fix suggestions
// Build prompt — paste into Cursor / Claude Code / Lovable / Bolt
Build ImageDiet, a GitHub Action plus a small Next.js site, that comments a Docker image size diff on every pull request. Stack: GitHub Actions (composite action wrapping a Node.js CLI), Node.js for analysis, Next.js for the marketing site and licence portal.

Core flow: the Action runs after the user's existing docker build step and takes the image tag as input. It inspects the image via docker save piped to tar parsing (no daemon API dependency beyond the local build), extracting per-layer sizes and the Dockerfile instruction that created each layer from the image history. For the comparison baseline, pull the most recent image built from the base branch: accept a registry ref pattern input like ghcr.io/org/app:main, falling back to a size manifest cached as a GitHub Actions artifact keyed by branch when no registry image exists.

The PR comment is one sticky comment (find and update by hidden HTML marker, never stack duplicates): total size with delta and percentage, a table of layers that changed with their Dockerfile lines, and the single worst offender called out at the top, e.g. plus 212 MB from RUN apt-get install at Dockerfile line 14. Add threshold inputs: warn-above and fail-above deltas in MB, so teams can hard-fail a PR that adds 300 MB.

Also flag known smells when detected: missing multi-stage build, apt cache not cleaned, node_modules copied before prune.

Pricing: free for public repos; private repos need a licence key input, 19 dollars a month per org, sold on the site.

// More Dev tool ideas