https://github.com/iopipe/awslambda-npm-install
Install any module, including native C/C++ modules for your NodeJS project on AWS Lambda
https://github.com/iopipe/awslambda-npm-install
Last synced: about 2 months ago
JSON representation
Install any module, including native C/C++ modules for your NodeJS project on AWS Lambda
- Host: GitHub
- URL: https://github.com/iopipe/awslambda-npm-install
- Owner: iopipe
- License: apache-2.0
- Created: 2017-07-06T19:45:09.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-19T23:10:31.000Z (about 7 years ago)
- Last Synced: 2025-02-13T13:16:48.598Z (3 months ago)
- Size: 9.77 KB
- Stars: 23
- Watchers: 6
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Native builder for AWS Lambda + NodeJS modules
----------------------------------------------This project allows users to easily install NodeJS modules,
including those written as addons with gyp in C/C++ for AWS Lambda.## Installation
The easiest way to use this is via a shell alias installed as such:
`$ echo 'alias awslambda-npm-install="docker run -v \$PWD:/var/task iopipe/awslambda-npm-install"' >> ~/.bashrc`
## Usage
From your project directory:
`$ awslambda-npm-install`
This will build C/C++ modules and install them into your `node_modules` directory using
the latest verison of NodeJS.That's it!
## Selecting version of NodeJS
Specify a Docker tag on the image name. Supported tags include:
* v8
* v6
* v4
* v8.10.0
* v6.10.2
* v4.3.2The tag may be specified as in the following command:
`docker run -v $PWD:/var/task iopipe/awslambda-npm-install:v4 `
## Building this Docker image
Build for NodeJS v4.3.2:
`docker build --build-arg NODE_VERSION=4.3.2 -t awslambda-npm-install .`
Build for NodeJS v6.10.2:
`docker build --build-arg NODE_VERSION=6.10.2 -t awslambda-npm-install .`
Build for NodeJS v8.10.0:
`docker build --build-arg NODE_VERSION=8.10.0 awslambda-npm-install .`
## Example project
The following example will create a new Serverless Framework project and add the native protocol buffers module.
```
$ serverless create -t aws-nodejs
$ docker run -v $PWD:/var/task iopipe/awslambda-npm-install protobuf
$ cat < handler.js
var protobuf = require('protobuf')
module.exports.hello = (event, context, callback) => {
callback()
}
EOF
$ serverless deploy
```## Technical details
This image is built on AWS Linux and builds its own versions
of NodeJS based on the versions used by AWS. None of these files
have been copied from the AWS Lambda environment, but are publicly
and legally available sources and binaries provided by AWS and the
NodeJS foundation for public and open use.## License
Apache-2.0 see [LICENSE](https://www.apache.org/licenses/LICENSE-2.0.html)
Copyright 2017 IOpipe, Inc.