Cut Docker Image Size by 400MB: Replace PuppeteerSharp with ShreePdf
Running Headless Chrome inside Kubernetes or AWS Lambda just to generate invoices and reports wastes hundreds of megabytes of RAM and bloats container images. Here is how ShreePdf compares.
| Production Metric | PuppeteerSharp / Playwright .NET | ShreePdf Engine (ShreePdf Vector) |
|---|---|---|
| Linux Docker Image Size (`aspnet:8.0`) | ~680 MB (with Chromium + 35 apt packages) | ~230 MB (Standard .NET image + `libfontconfig1`) |
| Cold-Start Time (First PDF) | 1,500 – 3,200 ms | 6.4 ms |
| Managed + Unmanaged Memory / Request | 380 – 650 MB (Zombie Chrome Processes) | ~14 MB (Deterministic `IDisposable` Stream) |
| `--no-sandbox` Security Risk in K8s | Required in unprivileged containers | None — Pure In-Process Library |
Dockerfile Comparison: 38 System Packages vs. Zero Browser Bloat
PuppeteerSharp Dockerfile (+450MB Layer)
Slow CI Builds
FROM mcr.microsoft.com/dotnet/aspnet:8.0
RUN apt-get update && apt-get install -y \
wget gnupg ca-certificates procps libxss1 \
libasound2 libatk-bridge2.0-0 libgtk-3-0 \
libnss3 libx11-xcb1 libxcb-dri3-0 libdrm2 \
libgbm1 libxshmfence1 fonts-ipafont-gothic \
&& rm -rf /var/lib/apt/lists/*
# Downloads 250MB+ Chromium at build or startup
ENTRYPOINT ["dotnet", "MyReportingApi.dll"]
ShreePdf Dockerfile (Slim & Instant)
-400MB Smaller
FROM mcr.microsoft.com/dotnet/aspnet:8.0
# Lightweight standard font support on Linux
RUN apt-get update && apt-get install -y libfontconfig1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "MyReportingApi.dll"]