serverless-chrome-ilkkah

1.0.20 • Public • Published

serverless-chrome

Serverless Chrome contains everything you need to get started running headless Chrome on AWS Lambda (possibly Azure and GCP Functions soon).

The aim of this project is to provide the scaffolding for using Headless Chrome during a serverless function invocation. Serverless Chrome takes care of building and bundling the Chrome binaries and making sure Chrome is running when your serverless function executes. In addition, this project also provides a few example services for common patterns (e.g. taking a screenshot of a page, printing to PDF, some scraping, etc.)

Why? Because it's neat. It also opens up interesting possibilities for using the Chrome DevTools Protocol in serverless architectures and doing testing/CI, web-scraping, pre-rendering, etc.

CircleCI Coveralls Codacy grade David David GitHub release

Contents

  1. The Project
  2. Quick Start
  3. Examples
  4. Chrome Version
  5. Testing
  6. Known Issues / Limitations
  7. Roadmap
  8. Projects & Companies using serverless-chrome
  9. Change log
  10. Prior Art

The Project

This project contains:

Quick Start

Using AWS Lambda, the quickest way to get started is with the Serverless-framework CLI.

First, install serverless globally:

npm install serverless -g

Then pull down the example service:

serverless install -u https://github.com/adieuadieu/serverless-chrome/tree/master/examples/serverless-framework/aws

Then, you must configure your AWS credentials either by defining AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environmental variables, or using an AWS profile. You can read more about this on the Serverless Credentials Guide.

In short, either:

export AWS_PROFILE=<your-profile-name>

or

export AWS_ACCESS_KEY_ID=<your-key-here>
export AWS_SECRET_ACCESS_KEY=<your-secret-key-here>

Then, to deploy the service and all of its functions:

serverless deploy

Further details are available in the Serverless Lambda example.

Examples

A collection of example functions for different providers and frameworks.

Serverless-framework

Chrome Version

The current Chrome build is:

  • Browser: HeadlessChrome/61.0.3135.0
  • Protocol-Version: 1.2
  • User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/61.0.3135.0 Safari/537.36
  • V8-Version: 6.1.201
  • WebKit-Version: 537.36 (@c671506faf285787f1c0377f90c8129a1a40a347)

Testing

Test with yarn test or just yarn ava to skip the linter.

Known Issues / Limitations

  1. Hack to Chrome code to disable /dev/shm. Details here.
  2. /tmp size on Lambda is only about 500MB.
  3. For steady/predictable loads, it might not be the most cost efficient to do this on Lambda vs. EC2

Roadmap

1.1

  1. Support for Google Cloud Functions
  2. Example for Apex
  3. Example for Claudia.js

1.2

  1. DOM manipulation and scraping example handler

Future

  1. Support for Azure Functions (Once Headless Chrome supports Windows)

Projects & Companies using serverless-chrome

Tell us about your project on the Wiki!

Change log

See the CHANGELOG

Prior Art

This project was inspired in various ways by the following projects:

Package Sidebar

Install

npm i serverless-chrome-ilkkah

Weekly Downloads

1

Version

1.0.20

License

MIT

Last publish

Collaborators

  • ile