1.0.0-beta • Published 5 years ago

@samjeffress/aws-lambda-brotli-unpacker v1.0.0-beta

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

aws-lambda-brotli-unpacker npm.io

Unpacks large Lambda binaries to /tmp, such as Tesseract, LibreOffice, Google Chrome, etc

Inspired by chrome-aws-lambda

Used in projects: aws-lambda-tesseract

Install

$ yarn add @shelf/aws-lambda-brotli-unpacker

Usage

Q: Why do I need this package?

A: It helps if you want to deploy pre-compiled software to use in Lambda. See list of projects where it is used above.

Q: Why bother?

A: Lambda environment has limited software installed. This package helps ship large binaries compiled for Lambda which unpack to /tmp folder when Lambda starts.

Q: Why /tmp?

A: Lambda has 500 MB of storage in /tmp

Q: Why brotli?

A: This compression algorithm is known for great speed/size ration. Perfect for scarce Lambda resources.

Example

const {unpack} = require('@shelf/aws-lambda-brotli-unpacker');
const {execSync} = require('child_process');

const inputPath = path.join(__dirname, '..', 'bin', 'tt.tar.br'); // for example, tesseract
const outputPath = '/tmp/tesseract/tesseract';

module.exports.handler = async event => {
  await unpack({inputPath, outputPath});

  execSync(`${outputPath} -l eng image.png`);
};

License

MIT © Shelf