fix(docker): install node + chromium + puppeteer for Browsershot PDF rendering - #65
Merged
Merged
Conversation
…rendering Production PDF rendering (spatie/laravel-pdf via Browsershot) failed with 'node: not found' (exit 127): the frankenphp runtime image had no Node/Chromium. Add system chromium (/usr/bin/chromium — matches laravel-pdf chrome_path), nodejs+npm, emoji/latin fonts, and Puppeteer installed globally with its own Chromium download skipped (uses the system chromium, no_sandbox=true). Verified end-to-end on the base image: puppeteer launches /usr/bin/chromium (--no-sandbox --disable-dev-shm-usage) and renders a PDF; full image builds. Affects both scheduled-report PDF attachments and the on-demand Download PDF. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Production PDF rendering fails with exit code 127:
spatie/laravel-pdfuses the Browsershot driver, which launches a headless browser via Node at runtime. Thedunglas/frankenphp:1-php8.4runtime image ships neither Node nor Chromium (Node only existed in the discarded frontend-builder stage), so every PDF render 500s. This affects both the new scheduled-report PDF attachments and the pre-existing on-demand Download PDF (Statistics /ReportController). Email + CSV delivery are unaffected.Fix
Add the Browsershot runtime requirements to the image (stage 2):
chromium(system browser at/usr/bin/chromium— matchesconfig/laravel-pdf.php'schrome_pathdefault), plusfonts-liberation+fonts-noto-color-emojito avoid missing-glyph boxes.nodejs+npm.puppeteerinstalled globally (Browsershot resolves it vianpm root -g) withPUPPETEER_SKIP_DOWNLOAD=trueso it reuses the system Chromium instead of downloading its own.no_sandbox=trueis already the config default.Verification
/usr/bin/chromium(--no-sandbox --disable-dev-shm-usage) and renders a PDF (node v20.19.2, chromium 151, puppeteer global).docker buildof the app image succeeds.Notes / follow-ups
--pull) or add documented.trivyignoreentries./dev/shm: Browsershot does not pass--disable-dev-shm-usageby default. For robustness with larger PDFs, setshm_size: '1gb'on the app service in the (server-managed) compose file. Current report PDFs are small, so the 64 MB default is normally fine.🤖 Generated with Claude Code