Zenika / alpine-chrome

Chrome Headless docker images built upon alpine official image
https://hub.docker.com/r/zenika/alpine-chrome
Apache License 2.0
1.82k stars 241 forks source link

unable to launch browser ENOENT #191

Closed hendrawan98 closed 1 year ago

hendrawan98 commented 2 years ago

Describe the bug im using zenika/alpine-chrome:with-node and running the docker file on railway.app the error what i get is

Error: Failed to launch the browser process! spawn /usr/src/app/node_modules/puppeteer/.local-chromium/linux-901912/chrome-linux/chrome ENOENT
TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
at onClose (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:197:20)
at ChildProcess.<anonymous> (/usr/src/app/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:189:85)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

and my Dockerfile is

FROM zenika/alpine-chrome:with-node

# Create app directory
WORKDIR /usr/src/app

COPY package.json yarn.lock ./

# Install deps
RUN yarn

# Bundle app source
COPY . .

# Start
CMD [ "yarn", "start" ]

my index.js

const puppeteer = require('puppeteer');

(async function() {
    const browser = await puppeteer.launch({ args: [
        '--enable-features=ExperimentalJavaScript',
        '--no-sandbox',
        '--disable-setuid-sandbox'
    ] })
    const page = await browser.newPage()
    await page.goto("https://example.com")
};)()
mewforest commented 2 years ago

I have the same problem :(

zigarn commented 2 years ago

Your puppeteer installs brings its own chrome which doesn't work in your case. Better is to use directly zenika/alpine-chrome:with-puppeteer to have puppeteer correctly setup. (Or you have to set the env var PUPPETEER_EXECUTABLE_PATH to point to /usr/bin/chromium-browser : https://github.com/Zenika/alpine-chrome/blob/c3f32c2b102c1ee2efd46fa4833491d7e956afaa/with-puppeteer/Dockerfile#L4)

anilbhanushali commented 2 years ago

two things,

  1. instead of puppeteer use puppeteer-core
  2. use the executable available in base image
    import puppeteer from "puppeteer-core";
    puppeteer
    .launch({
    executablePath: "/usr/bin/chromium-browser",
    })