How can I run puppeteer on Fly.io

I’ve updated dockerfile-node to support puppeteer. You can have it update your Dockerfile by issuing the following commands:

npm update @flydotio/dockerfile
npx dockerfile

If you would prefer to make these changes yourself, you can see a working Dockerfile at: https://github.com/fly-apps/dockerfile-node/blob/main/test/base/puppeteer/Dockerfile

Chrome is a memory hog. At a minimum, you will likely need 1G of RAM. See fly scale memory · Fly Docs and Fly Launch configuration (fly.toml) · Fly Docs for options.

You also are going to want to run headless and without a sandbox:

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