Hey team,
I’m trying to run puppeteer and it seems like there are some issues with spawning the browser.
Docker file:
# Use the official lightweight Node.js 12 image.
# https://hub.docker.com/_/node
FROM node:14-alpine
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package*.json ./
# Install dependencies
RUN yarn
# Copy local code to the container image.
COPY . ./
# Expose the port
EXPOSE 80
# Build the application
RUN yarn build
# Run the web service on container startup.
CMD [ "yarn", "start:prod" ]
Task:
const browser = await puppeteer.launch({ args: ["--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage", "--disable-extensions"] });
try {
const page = await browser.newPage();
await page.setContent(`<p>This is but an example</p>`});
await page.addStyleTag({ path: this.config.css() })
await page.evaluateHandle(EVALUATE_FONTS); // wait for fonts loading
(...)
It breaks on launching the puppeteer
browser instance, here’s the look:
Error: Failed to launch the browser process! spawn /usr/src/app/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome ENOENT
Nov 19 08:29:11 PM TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
Nov 19 08:29:11 PM
Nov 19 08:29:11 PM at onClose (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
Nov 19 08:29:11 PM at ChildProcess.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:189:85)
Nov 19 08:29:11 PM at ChildProcess.emit (events.js:400:28)
Nov 19 08:29:11 PM at ChildProcess.emit (domain.js:475:12)
Nov 19 08:29:11 PM at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
Nov 19 08:29:11 PM at onErrorNT (internal/child_process.js:469:16)
Nov 19 08:29:11 PM at processTicksAndRejections (internal/process/task_queues.js:82:21)
FYI: It works fine on local (same docker) and Heroku. I’m no expert but it looks like there’s some deps missing