Invoice PDFs without Chromium in your app image: three ways to wire the renderer

Baking Chromium into a Node image to render invoice PDFs adds roughly 600-720 MB. Measured sizes, the memory it costs, and the two ways to keep it out.

An open-source app wanted to email invoices and statements as PDF attachments. The obvious move was to put Chromium in the Docker image, and the issue that tracked it is unusually frank about what happened next: the image went from 294 MB to 614 MB compressed, 1.6 GB to 2.68 GB unpacked. Two days later the browser was out of the image and the renderer had become a setting: none, a local Chrome, or an external render service.

That three-way fork is the real decision, and it's worth making on numbers rather than on taste. So I built the images.

What Chromium costs in a Node image

Same base, same Playwright version, two variants. The only difference between them is which browser build gets installed:

FROM node:22-slim
WORKDIR /app
RUN npm init -y && npm i playwright@1.63.0 \
 && npx playwright install --with-deps --only-shell chromium \
 && rm -rf /var/lib/apt/lists/* /root/.npm

(--no-shell instead of --only-shell for the full browser.) Measured on Nov 21, 2026:

image unpacked compressed
node:22-slim on its own 232 MB 80 MB
+ Playwright + headless shell 824 MB 324 MB
+ Playwright + full Chromium 956 MB 396 MB

Unpacked is du over the container's filesystem; compressed is the gzipped docker save, which tracks what a registry stores closely but not exactly.

The surprise is where the weight goes. The headless shell itself is 261 MB on disk. The rest of the ~590 MB it adds is the system libraries and fonts that --with-deps installs so the browser can start at all. You can't skip those, and they don't shrink when you pick the smaller browser.

Disk isn't the whole bill. Rendering one 40-row invoice to Letter on a warm page, the headless shell's processes sat at roughly 390-410 MB of resident memory, and full Chromium at 710-730 MB. Every replica of your app carries that, whether it renders one invoice a day or none.

Option 1: keep it in the image, but use the headless shell

This is the simplest wiring and at low volume it's the right one. One container, no network hop, the invoice data never leaves your box. If you go this way:

  • install the headless shell, not the full browser. It's smaller on disk, used about half the memory, and rendered our invoice in 6-7 ms against 16-20 ms (the two builds here were different Chromium versions, so read the ratio, not the decimals);
  • reuse one browser and open a page per render, rather than launching per request;
  • block network requests the template doesn't need, or one slow asset will hold the render until it times out.

The cost is that every app replica pays the memory and the image size, and you're patching a browser on your app's release cycle.

Option 2: a render sidecar

Run the browser as its own service (Gotenberg, or a small Playwright server you write) and call it over HTTP. Your app image goes back to roughly its base size (node:22-slim is ~80 MB compressed), and the browser scales on its own schedule: one renderer can serve many app replicas.

What you take on is a second service to run, patch and lock down. A renderer that loads arbitrary HTML will fetch whatever URLs that HTML points to unless you tell it not to, so it belongs on a private network with outbound access restricted.

Option 3: a hosted API

Send a template and JSON, get a file back. Nothing to run. iReceipt PRO is one of these: templates are HTML, CSS and Mustache, stored once, and each invoice is a single request carrying that invoice's data. Output is PDF, PNG, JPG or WEBP.

The honest costs: a network call per document, and the invoice data leaves your infrastructure. Per the FAQ, templates can't run JavaScript or load external resources (images go in base64), which rules out some layouts and also removes the stalled-asset problem entirely. Authoring your own template needs a paid plan.

Which one

A handful of invoices a day, one app instance: option 1 with the headless shell. It's fine, and adding a service to avoid 600 MB of disk is overkill.

Several replicas, or an image size someone is paying for in cold starts: move the browser out. Sidecar if you're happy running it and the data must stay in-house; a hosted API if you'd rather not own a browser at all.

What I wouldn't do is bake full Chromium into every replica just because it was the first thing that worked.