jontewks/puppeteer-heroku-buildpack

Upstream package puppeteer's xdg-utils dependency adds 344 MiB (๐Ÿ˜ฑ) to image sizes

Nitrodist opened this issue ยท 2 comments

Hey y'all, I just wanted to reference this issue identified in our lovely README.md file in an upstream puppeteer GitHub issue.

A dependency xdg-utils is normally needed to install puppeteer - this balloons the size of heroku images/containers by 344 MiB (images/containers called 'slugs' in Heroku parlance). There is an experimental branch by the authors of this repo where we don't install it and it seems to work OK if you do not need to use those features, thus saving 344MiB.

It would be nice if the puppeteer owners replaced their use of xdg-utils with something more lightweight and then we would not need to risk using the modified version and causing an exception in a production environment. So I've created this issue until it's fixed upstream in https://github.com/puppeteer/puppeteer ๐Ÿš€

From the README

Slug Size

A common issue is running into slug size maximums when using this buildpack. Unfortunately the chromium bundled with Puppeteer requires some packages to be installed on Heroku that are quite large. The list of common missing requirements on Debian for Puppeteer can be found here: https://pptr.dev/troubleshooting, and the list of available packages on each Heroku stack by default can be found here: https://devcenter.heroku.com/articles/stack-packages#installed-ubuntu-packages. This buildpack only installs things in the first list that aren't found in the second list and their sizes are as follows:

Package Size (mb)
fonts-liberation 2.1
libappindicator3-1 55.2
libasound2 2.4
libatk-bridge2.0-0 3.9
libatk1.0-0 0.2
libgbm1 0.4
libgtk-3-0 54.8
libnspr4 0.3
libnss3 4.2
libx11-xcb1 0.1
libxcomposite1 0.03
libxcursor1 0.1
libxdamage1 0.03
libxfixes3 0.05
libxi6 0.1
libxrandr2 0.07
libxss1 0.03
libxtst6 0.05
xdg-utils 344 ๐Ÿ˜ฑ

Some of these are quite large but unfortunately there is nothing we can do about it at the moment if we are following Puppeteer's list of requirements exactly.

I did try to deploy a very minimal Puppeteer app on Heroku without installing xdg-utils since that was the largest library by far, and to my surprise the app still worked. I'm assuming there will be some functionality within Puppeteer that won't work due to the missing library, but perhaps if you aren't doing anything that requires that library, you can get away with this other release that doesn't include that library to dramatically reduce your slug size. It's an experiment though so don't use this for very critical things as I have no idea when it might stop working for you.

https://github.com/jontewks/puppeteer-heroku-buildpack/releases/tag/22.0.0-no-xdg-utils

$ heroku buildpacks:add https://github.com/jontewks/puppeteer-heroku-buildpack#22.0.0-no-xdg-utils

If you are still running into any issues with this buildpack after doing the above, please open an issue on this repo and/or submit a PR that resolves it. Different versions of chrome have different dependencies and so some issues can creep in without me knowing. Thanks!

Hmm, I wonder if we can switch to using a precompiled version that doesn't require the compile-time dependencies of xdg-utils (I think?)

Hey @Nitrodist, sorry if I'm not understanding here, but why did you create this issue? Just to reference something in the readme of this same repo?

Is there a specific ask here for a change to the buildpack?