4

Dokku is an alternative for Heroku, with a self hosted version.

I try to use Puppeteer Chrome headless with this code:

const browser = await puppeteer.launch({
     headless: true,
     args: [
          '--no-sandbox',
          '--disable-setuid-sandbox'
     ]
});

const page = await browser.newPage();

When Dokku build and launch the app, I get this error:

Error: Failed to launch chrome! /app/node_modules/puppeteer/.local-chromium/linux-641577/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory TROUBLESHOOTING: https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md

The troubleshooting page say to install packages. But Dokku haven't access to this installed package because he working with Docker.

Also, I've installed buildpack with this command:

dokku buildpacks:add <app_name> jontewks/puppeteer

or this git repository

dokku buildpacks:add <app_name> https://github.com/jontewks/puppeteer-heroku-buildpack.git

I execute the deploy command again dokku deploy <app_name> and I've always errors in logs.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
pirmax
  • 2,054
  • 8
  • 36
  • 69

1 Answers1

1

I'm going to answer this if anyone run into the same problem (like I did). A solution has been proposed in a github project by mskog.

The root cause for the inability of puppeteer to launch is because some libraries are missing in the container. So, you need to install them when creating it. For that, mskog propose to use dokku-apt, a plugin for Dokku that will install the libraries for you when the container is started.

After installing dokku-apt, create a file named apt-packages at the root of your project and add the list of required libraries in it.

Since version 3.0, puppeteer requires a new library libgbm-dev that is not specified in the github project, use the following list below.

gconf-service
libasound2
libatk1.0-0
libc6
libcairo2
libcups2
libdbus-1-3
libexpat1
libfontconfig1
libgcc1
libgconf-2-4
libgdk-pixbuf2.0-0
libglib2.0-0
libgtk-3-0
libnspr4
libpango-1.0-0
libpangocairo-1.0-0
libstdc++6
libx11-6
libx11-xcb1
libxcb1
libxcomposite1
libxcursor1
libxdamage1
libxext6
libxfixes3
libxi6
libxrandr2
libxrender1
libxss1
libxtst6
ca-certificates
fonts-liberation
libappindicator1
libnss3
lsb-release
libgbm-dev
xdg-utils
wget
joprocorp
  • 176
  • 10