jontewks/puppeteer-heroku-buildpack

Achieve smaller sizes

Opened this issue · 10 comments

I noticed that the size of the final app whenever I used puppeteer-heroku-buildpack was about 431MB instead of ~110MB.
Now I tried something else. I used puppeteer-core, and heroku/google-chrome buildpack. So I now launch puppeteer and specifying browser path to /app/.apt/usr/bin/google-chrome(installed by the heroku/google-chrome buildpack). In the end, I never had to pass in funny arguments like --no-sandbox, and achieved a much smaller build size: 212MB.

So, is there a way to have that seductively smaller build size, along with the short time it takes to build my app each time I commit ?

I'm having issue with file size

Compiled slug size: 503.2M is too large (max is 500M).
See: http://devcenter.heroku.com/articles/slug-size
Push failed

This is from Puppeteer's docs:
image

So while obviously you got it working with that setup, I don't want to require people to do a certain setup to get the buildpack working. All this does is add a few very small libraries to allow the bundled chromium with Puppeteer to work on Heroku. Puppeteer is the bulk of the slug size since it installs chromium.

I'd suggest checking you're up-to-date with the version of Puppeteer as they had an issue with install size a while ago and I believe it's resolved now.

If you've found a good setup working on Heroku then no reason to change it. If you want to use the chromium bundled with Puppeteer for the stability that setup provides then this buildpack will make that happen.

@kevgilmore here is a comment from a previous time slug sizes came up with a potential fix. When I used this previously at work we just had to split out the Puppeteer stuff from the rest of the app it was working with and treat it as a microservice as the chromium install took up so much room.

#103 (comment)

Actually it looks like I'm wrong. I don't know if I messed up the addition in that comment or if something changed in Heroku-22 but this buildpack is adding a lot to the slug where I was under the impression it wasn't doing that in the past. Let me see if I can make a slimmed down version for Heroku-22 specifically or if we are just stuck needing these dependencies to get Puppeteer running.

WIll update soon.

Did what I could, but it looks like one of the requirements for Puppeteer to run that isn't included from Heroku by default on any of their modern stacks is 344MB. Puppeteer won't run without it, so not a lot we can do unfortunately here. I updated the readme with the links to the lists of requirements and what's available on Heroku, as well as their disk space usage sizes.

xdg-utils is listed as required by Puppeteer but just for fun I tried running my test app without that library included, and it still worked. I'm assuming there is going to be some functionality that doesn't work in Puppeteer due to this library missing, but perhaps if you aren't doing whatever its for it will work for you and ends up with a much smaller slug size. The release is here and new instructions on how to install a specific release are in the README.
https://github.com/jontewks/puppeteer-heroku-buildpack/releases/tag/22.0.0-no-xdg-utils

Thanks alot

xdg-utils is listed as required by Puppeteer but just for fun I tried running my test app without that library included, and it still worked. I'm assuming there is going to be some functionality that doesn't work in Puppeteer due to this library missing, but perhaps if you aren't doing whatever its for it will work for you and ends up with a much smaller slug size. The release is here and new instructions on how to install a specific release are in the README. https://github.com/jontewks/puppeteer-heroku-buildpack/releases/tag/22.0.0-no-xdg-utils

It turns out xdg-utils is not very useful, since it is used to manage desktop environments. We clearly do not need this, since puppeteer is headless.

xdg-utils is listed as required by Puppeteer but just for fun I tried running my test app without that library included, and it still worked. I'm assuming there is going to be some functionality that doesn't work in Puppeteer due to this library missing, but perhaps if you aren't doing whatever its for it will work for you and ends up with a much smaller slug size. The release is here and new instructions on how to install a specific release are in the README. https://github.com/jontewks/puppeteer-heroku-buildpack/releases/tag/22.0.0-no-xdg-utils

Hey @jontewks I added the build pack without xdg-utils like:

heroku buildpacks:add https://github.com/jontewks/puppeteer-heroku-buildpack#22.0.0-no-xdg-utils -a <my-app>

I've cleared the cache but when installing I still see this:

-----> Installing xdg-utils_1.1.3-4.1ubuntu1.22.04.1_all.deb
-----> Installing xkb-data_2.33-1_all.deb

and the slug size is 400MB+

is there something im missing or doing wrong?

Hmm ran the purge cache command again, just to try haha, and yeah, now its down to 200MB!