@@ -8,10 +8,13 @@ module may not be compatible with the Amazon Lambda execution environment.
88A common solution to this problem is to build the package on an EC2 instance using an Amazon Linux AMI and then to
99deploy it in Amazon Lambda. Building serverless applications, it is ironic to be obliged to use an EC2 server to deploy code.
1010
11- This docker image is based on the [ Amazon Linux 1] ( https://hub.docker.com/_/amazonlinux/ ) image and contains ` gcc ` ,
12- ` python 2.7 ` , ` python 3.6 ` , ` python 3.7 ` , ` pip ` , ` node 6.10 ` , ` node 8.10 ` to create packages for Amazon Lambda.
11+ This docker image is based on the [ Amazon Linux] ( https://hub.docker.com/_/amazonlinux/ ) image and contains ` gcc ` .
1312
14- Using the docker image ` myrmex/lambda-packager ` , you can avoid errors like these during execution in Amazon Lambda:
13+ The docker image ` myrmex/lambda-packager:1 ` contains ` python 2.7 ` , ` python 3.6 ` , ` python 3.7 ` , ` pip ` , ` node 6.10 ` , ` node 8.10 ` to create packages for Amazon Lambda.
14+
15+ The docker image for ` myrmex/lambda-packager:2 ` contains ` node 10.16 ` to create packages for Amazon Lambda.
16+
17+ Using the docker images from ` myrmex/lambda-packager ` , you can avoid errors like these during execution in Amazon Lambda:
1518
1619```
1720/var/lang/lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /var/task/node_modules/bcrypt/lib/binding/bcrypt_lib.node)
@@ -24,18 +27,24 @@ Module version mismatch. Expected 46, got 48.
2427## Usage
2528
2629You can use a docker volume to mount the code of the Lambda in a container. The directory where ` npm install ` or
27- ` pip install ` is executed inside the container is ` /data ` . By default, the installation will be performed for node
28- 6.10.
30+ ` pip install ` is executed inside the container is ` /data ` . By default, the installation will be performed for node.
2931
3032``` bash
31- docker run -v ` pwd` :/data myrmex/lambda-packager
33+ docker run -v ` pwd` :/data myrmex/lambda-packager:1
3234```
3335
3436The image does not create the zip archive for your. It only installs the dependencies in an environment compatible with
3537Lambda. You will still have to zip the result and deploy it in Amazon Lambda.
3638
3739For a node package, take care that ` node_module ` does not already exist before running the command.
3840
41+ ## Building images locally
42+
43+ ``` bash
44+ docker build -t myrmex/lambda-packager:1 -f al1.Dockerfile .
45+ docker build -t myrmex/lambda-packager:2 -f al2.Dockerfile .
46+ ```
47+
3948### Managing permissions
4049
4150The user account that performs ` npm install ` or ` pip install ` inside the container may have a ` uid/gid ` that differs from the
@@ -51,37 +60,48 @@ docker run -e HOST_UID=`id -u` -e HOST_GID=`id -g` -v `pwd`:/data myrmex/lambda-
5160
5261The ` RUNTIME ` environment variable allows to choose the runtime.
5362
63+ ### Node 10.16
64+
65+ Node 10.16 is the default runtime for ` Amazon Linux 2 ` and does not require any special configuration.
66+
67+ ``` bash
68+ docker run -v ` pwd` :/data myrmex/lambda-packager:2
69+ ```
5470
5571#### Node 8.10
5672
57- Node 8.10 is the default runtime and does not require any special configuration.
73+ Node 8.10 is the default runtime for ` Amazon Linux ` and does not require any special configuration.
74+
75+ ``` bash
76+ docker run -v ` pwd` :/data myrmex/lambda-packager:1
77+ ```
5878
5979#### Node 6.10
6080
6181``` bash
62- docker run -e RUNTIME=node6 -v ` pwd` :/data myrmex/lambda-packager
82+ docker run -e RUNTIME=node6 -v ` pwd` :/data myrmex/lambda-packager:1
6383```
6484
6585#### Python 3.7
6686
6787Python 3.7 is the default Python 3 runtime and accepts the values ` python3 ` or ` python3.7 `
6888
6989``` bash
70- docker run -e RUNTIME=python3.7 -v ` pwd` :/data myrmex/lambda-packager
90+ docker run -e RUNTIME=python3.7 -v ` pwd` :/data myrmex/lambda-packager:1
7191```
7292
7393#### Python 3.6
7494
7595``` bash
76- docker run -e RUNTIME=python3.6 -v ` pwd` :/data myrmex/lambda-packager
96+ docker run -e RUNTIME=python3.6 -v ` pwd` :/data myrmex/lambda-packager:1
7797```
7898
7999#### Python 2.7
80100
81101Accepts the values ` python ` or ` python2 ` .
82102
83103``` bash
84- docker run -e RUNTIME=python -v ` pwd` :/data myrmex/lambda-packager
104+ docker run -e RUNTIME=python -v ` pwd` :/data myrmex/lambda-packager:1
85105```
86106
87107### Default command
0 commit comments