Szpadel / chrome-headless-render-pdf

223 stars 67 forks source link

AWS Lambda #47

Closed Prinzhorn closed 5 years ago

Prinzhorn commented 5 years ago

This is just for people like me who are trying to get this to work on Lambda. Now there's a search result, yay.

I'm using the binary from https://github.com/adieuadieu/serverless-chrome/releases

I had to add a few flags to make it run:

{
  chromeBinary: 'bin/headless-chromium-you-have-downloaded',
  chromeOptions: ['--disable-dev-shm-usage', '--no-zygote', '--single-process', '--no-sandbox']
}

Source: https://github.com/adieuadieu/serverless-chrome/blob/886c2c4f5c5b2e8f9b79670e0935ee8afb970aab/packages/lambda/src/flags.js

sb39 commented 3 years ago

@Prinzhorn can you include the steps ? I am using https://github.com/shelfio/chrome-aws-lambda-layer but have no idea actually how to use it on the runtime

Prinzhorn commented 3 years ago

I am using https://github.com/shelfio/chrome-aws-lambda-layer

I'm not using layers, I literally just had the binary in my project and pointed chromeBinary to it

I've switched to https://github.com/alixaxel/chrome-aws-lambda and it works out of the box. Having access to puppeteer gives you all the options you need.

sb39 commented 3 years ago

Do you have any sample snippet which I can refer. I can't install pupetter on aws lambda, its over 250mb. My package is not getting uploaded. So needed an alternative

Prinzhorn commented 3 years ago

I'm literally using https://github.com/alixaxel/chrome-aws-lambda#usage

Prinzhorn commented 3 years ago

It's puppeteer-core, I have puppeteer as devDependencies so it's used only locally