3

Hi I have a super simple Dockerfile to run puppeteer in Docker:

FROM node:12.2.0-alpine

RUN apk update && apk upgrade && \
  echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
  echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
  apk add --no-cache \
  bash=4.4.19-r1 \
  git=2.20.1-r0 \
  openssh=7.9_p1-r5 \
  chromium@edge \
  nss@edge \
  freetype@edge \
  harfbuzz@edge \
  ttf-freefont@edge \
  sudo=1.8.25_p1-r2

ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 /usr/local/bin/dumb-init
RUN chmod +x /usr/local/bin/dumb-init
ENTRYPOINT ["dumb-init", "--"]

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true

WORKDIR /app

COPY package.json .

RUN npm install --quiet -g pm2@^3.5.1 && \
    npm install puppeteer@1.19.0 && \
    npm install --quiet

COPY app.js ./app.js

RUN addgroup -S pptruser && adduser -S -g pptruser pptruser \
  && mkdir -p /home/pptruser/Downloads \
  && chown -R pptruser:pptruser /home/pptruser \
  && chown -R pptruser:pptruser /app

USER pptruser

EXPOSE 1337

CMD [ "pm2-runtime", \
    "start", "app.js", \
    "-i", "max", \
    "--max-memory-restart", "1700M", \
    "--cron", "0 */12 * * *" \
]

This was a working solution until now wehn I have run yum update on my centos7 host machine. Right after that, the app refuses to work properly generating the following error:

Error: LAUNCH_BROWSER
    at /app/node_modules/async/dist/async.js:171:65
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
Error: Failed to launch chrome!
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found
Error relocating /usr/lib/chromium/chrome: _ZNSt19_Sp_make_shared_tag5_S_eqERKSt9type_info: symbol not found

I have failed to find a solution so far to put it back in order :-( Any advice appreciated.

David Zaba
  • 67
  • 1
  • 9
  • Seems you're missing some debian dependencies: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md – mahmoudafer Sep 28 '19 at 12:31

1 Answers1

3

There is currently a problem with the recent Chromium version on alpine. See these two issues on github for more information:

Solution

The solution for now is to downgrade the Chromium version to version 72. Some users also reported that version 73 worked for them. You could also give that a try (chromium@edge=73.0.3683.103-r0).

In addition to downgrading Chromium, you also need to downgrade puppeteer to the corresponding version. For Chromium 72 you need to use version 1.11.0. (more information on how to detect the Chrome version to use with puppeteer)

The changed Dockerfile:

RUN apk update && apk upgrade && \
  ...
  chromium@edge=72.0.3626.121-r0 \
...

RUN ...
    npm install puppeteer@1.11.0 && \
Thomas Dondorf
  • 23,416
  • 6
  • 84
  • 105
  • It does not appear to be a working solution as downgrading to 72... generates a different puppeteer-related err: Error: Protocol error (Fetch.enable): 'Fetch.enable' wasn't found at /app/node_modules/puppeteer/lib/Connection.js:183:56 at new Promise () at CDPSession.send (/app/node_modules/puppeteer/lib/Connection.js:182:12) at NetworkManager._updateProtocolRequestInterception (/app/node_modules/puppeteer/lib/NetworkManager.js:145:22) at NetworkManager.setRequestInterception (/app/node_modules/puppeteer/lib/NetworkManager.js:134:16) at ... – David Zaba Sep 28 '19 at 18:40
  • @DavidZaba Can you try to downgrade puppeteer to version `v1.11.0` (when using chromium 72)? That's the version to be used with that chromium version. – Thomas Dondorf Sep 28 '19 at 18:44
  • 2
    Using v1.11.0 removes the mentioned error, but the app does not work. I belive it is because the app contains new puppeteer APIs that have been introduced in > 1.11.0 versions. It is a real pitty as we would need to look where to downgrade the app as well. I wish the whole puppeteer thing was more stable. Anyway, I will accept your answer. – David Zaba Sep 28 '19 at 19:13
  • @DavidZaba I added the information to the answer. Sorry, I guess this is the best option until the bugs are fixed. – Thomas Dondorf Sep 28 '19 at 19:52