Error with puppeteer with alpine Docker in chromium headless

2.5k views Asked by At

I'm trying to use pageres in my bash script for grabbing screenshot in heruko. But running pageres with alpine:latest throws error with puppeteer.

Error: Failed to launch the browser process!
[0318/133905.228580:FATAL:setuid_sandbox_host.cc(158)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /usr/lib/chromium/chrome-sandbox is owned by root and has mode 4755.
Received signal 6
  r8: 00007fff02e9e180  r9: 00007f65b4e1eb0c r10: 0000000000000008 r11: 0000000000000246
 r12: 00007fff02e9e820 r13: 00007fff02e9e95c r14: 00007fff02e9e5f0 r15: 0000000000000116
  di: 0000000000000002  si: 00007fff02e9e010  bp: 00007fff02e9e010  bx: 0000000000000000
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f65b96113f1  sp: 00007fff02e9e008
  ip: 00007f65b96113f1 efl: 0000000000000246 cgf: 0000000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/usr/local/lib/node_modules/pageres-cli/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/pageres-cli/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:184:79)
    at ChildProcess.emit (node:events:532:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

I followed the troubleshooting docs at puppeteer git and added these lines to my dockerfile:


# Installs latest Chromium (92) package.
RUN apk add --no-cache \
      chromium \
      nss \
      freetype \
      harfbuzz \
      ca-certificates \
      ttf-freefont \
      nodejs \
      yarn

# Tell Puppeteer to skip installing Chrome. We'll be using the installed package.
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

# Puppeteer v10.0.0 works with Chromium 92.
RUN yarn add [email protected]

# Add user so we don't need --no-sandbox.
RUN addgroup -S pptruser && adduser -S -G pptruser pptruser \
    && mkdir -p /home/pptruser/Downloads /app \
    && chown -R pptruser:pptruser /home/pptruser \
    && chown -R pptruser:pptruser /app

Also I tried firefox in headless mode for grabbing screenshot, that too throws error...

*** You are running in headless mode.
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.323898) [GFX1-]: glxtest: libpci missing
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.323898) |[1][GFX1-]: glxtest: libGL.so.1 missing (t=0.32393) [GFX1-]: glxtest: libGL.so.1 missing
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.323898) |[1][GFX1-]: glxtest: libGL.so.1 missing (t=0.32393) |[2][GFX1-]: glxtest: libEGL missing (t=0.323941) [GFX1-]: glxtest: libEGL missing
Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: libpci missing (t=0.323898) |[1][GFX1-]: glxtest: libGL.so.1 missing (t=0.32393) |[2][GFX1-]: glxtest: libEGL missing (t=0.323941) |[3][GFX1-]: No GPUs detected via PCI (t=0.323959) [GFX1-]: No GPUs detected via PCI

But sadly nothing worked. Can I have a fix or better way for doing it?

Edit: Chromium version - 93.0.4577.82, Firefox version - 94.0, Puppeteer version - 10.0.0

1

There are 1 answers

1
jonny133 On

Did you add the last line in those docs?

# Run everything after as non-privileged user.
USER pptruser