Skip to content

Commit 89d50ac

Browse files
Update runtimes
- Dropped support for node v4 as it was marked EOL on 2018-04-30 - Bumped minor version of node v6 - Bumped minor version of python v3.6 - Added python3.7 support - Default python3 runtime is 3.7
1 parent 6790298 commit 89d50ac

File tree

3 files changed

+76
-33
lines changed

3 files changed

+76
-33
lines changed

Dockerfile

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,17 @@ FROM amazonlinux:1
33
MAINTAINER Alexis N-o "[email protected]"
44

55
ENV DEFAULT_USER=myrmex
6-
ENV NODE_VERSION_4 4.3.2
7-
ENV NODE_VERSION_6 6.10.2
6+
ENV NODE_VERSION_6 6.10.3
87
ENV NODE_VERSION_8 8.10.0
8+
ENV PYTHON_VERSION_3_6 3.6.8
9+
ENV PYTHON_VERSION_3_7 3.7.3
910

1011
# Install gcc add utilities to manage users and permissions
1112
RUN yum install -y gcc-c++ util-linux shadow-utils zlib-devel openssl-devel libffi-devel
1213

13-
# Install node v4 node v6 and node v8 as commands "node4" "node6" and "node8"
14+
# Install node v6 and node v8 as commands "node6" and "node8"
1415
# Command "node" defaults to v8
15-
# Update npm to version 4
1616
RUN cd /opt &&\
17-
curl -O https://nodejs.org/dist/v${NODE_VERSION_4}/node-v${NODE_VERSION_4}-linux-x64.tar.gz &&\
18-
tar xvzf node-v${NODE_VERSION_4}-linux-x64.tar.gz &&\
19-
ln -s /opt/node-v${NODE_VERSION_4}-linux-x64/bin/node /usr/local/bin/node4 &&\
20-
ln -s /opt/node-v${NODE_VERSION_4}-linux-x64/bin/node /usr/local/bin/node &&\
21-
ln -s /opt/node-v${NODE_VERSION_4}-linux-x64/bin/npm /usr/local/bin/npm &&\
22-
/opt/node-v${NODE_VERSION_4}-linux-x64/bin/npm install -g npm@4 &&\
23-
rm /usr/local/bin/node /usr/local/bin/npm &&\
2417
curl -O https://nodejs.org/dist/v${NODE_VERSION_6}/node-v${NODE_VERSION_6}-linux-x64.tar.gz &&\
2518
tar xvzf node-v${NODE_VERSION_6}-linux-x64.tar.gz &&\
2619
ln -s /opt/node-v${NODE_VERSION_6}-linux-x64/bin/node /usr/local/bin/node6 &&\
@@ -35,17 +28,28 @@ RUN cd /opt &&\
3528
ln -s /opt/node-v${NODE_VERSION_8}-linux-x64/bin/npm /usr/local/bin/npm &&\
3629
/opt/node-v${NODE_VERSION_8}-linux-x64/bin/npm install -g npm@4
3730

38-
# Install python 3.6 and pip, python 2.7 is already available
31+
# Install python 3.6 and python 3.7 including pip, python 2.7 is already available
32+
# Command "python3" defaults to 3.7
3933
RUN curl -O https://bootstrap.pypa.io/get-pip.py &&\
4034
python get-pip.py &&\
41-
curl -O https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz &&\
42-
tar zxvf Python-3.6.1.tgz &&\
43-
cd Python-3.6.1 &&\
44-
./configure --prefix=/opt/python3 &&\
35+
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION_3_6}/Python-${PYTHON_VERSION_3_6}.tgz &&\
36+
tar zxvf Python-${PYTHON_VERSION_3_6}.tgz &&\
37+
cd Python-${PYTHON_VERSION_3_6} &&\
38+
./configure --prefix=/opt/python-${PYTHON_VERSION_3_6} &&\
39+
make &&\
40+
make install &&\
41+
ln -s /opt/python-${PYTHON_VERSION_3_6}/bin/python3 /usr/bin/python3.6 &&\
42+
ln -s /opt/python-${PYTHON_VERSION_3_6}/bin/pip3 /usr/bin/pip3.6 && \
43+
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION_3_7}/Python-${PYTHON_VERSION_3_7}.tgz &&\
44+
tar zxvf Python-${PYTHON_VERSION_3_7}.tgz &&\
45+
cd Python-${PYTHON_VERSION_3_7} &&\
46+
./configure --prefix=/opt/python-${PYTHON_VERSION_3_7} &&\
4547
make &&\
4648
make install &&\
47-
ln -s /opt/python3/bin/python3 /usr/bin/python3 &&\
48-
ln -s /opt/python3/bin/pip3 /usr/bin/pip3
49+
ln -s /opt/python-${PYTHON_VERSION_3_7}/bin/python3 /usr/bin/python3.7 &&\
50+
ln -s /opt/python-${PYTHON_VERSION_3_7}/bin/pip3 /usr/bin/pip3.7 &&\
51+
ln -s /opt/python-${PYTHON_VERSION_3_7}/bin/python3 /usr/bin/python3 &&\
52+
ln -s /opt/python-${PYTHON_VERSION_3_7}/bin/pip3 /usr/bin/pip3
4953

5054

5155
# Add a script to modify the UID / GID for the default user if needed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
## Why?
44

55
Some node and python modules require a build system because they contain c++ binding. Once deployed, the compiled
6-
module may not be complatible with the Amazon Lambda execution environment.
6+
module may not be compatible with the Amazon Lambda execution environment.
77

88
A common solution to this problem is to build the package on an EC2 instance using an Amazon Linux AMI and then to
99
deploy 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](https://hub.docker.com/_/amazonlinux/) image and contains `gcc`,
12-
`python 2.7`, `python 3.6`, `pip`, `node 4.3`, `node 6.10` and `npm 4` to create packages for Amazon Lambda.
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.
1313

1414
Using the docker image `myrmex/lambda-packager`, you can avoid errors like these during execution in Amazon Lambda:
1515

@@ -51,20 +51,29 @@ docker run -e HOST_UID=`id -u` -e HOST_GID=`id -g` -v `pwd`:/data myrmex/lambda-
5151

5252
The `RUNTIME` environment variable allows to choose the runtime.
5353

54+
55+
#### Node 8.10
56+
57+
Node 8.10 is the default runtime and does not require any special configuration.
58+
5459
#### Node 6.10
5560

56-
Node 6.10 is the default runtime and does not require any special configuration.
61+
```bash
62+
docker run -e RUNTIME=node6 -v `pwd`:/data myrmex/lambda-packager
63+
```
64+
65+
#### Python 3.7
5766

58-
#### Node 4.3
67+
Python 3.7 is the default Python 3 runtime and accepts the values `python3` or `python3.7`
5968

6069
```bash
61-
docker run -e RUNTIME=node4 -v `pwd`:/data myrmex/lambda-packager
70+
docker run -e RUNTIME=python3.7 -v `pwd`:/data myrmex/lambda-packager
6271
```
6372

6473
#### Python 3.6
6574

6675
```bash
67-
docker run -e RUNTIME=python3 -v `pwd`:/data myrmex/lambda-packager
76+
docker run -e RUNTIME=python3.6 -v `pwd`:/data myrmex/lambda-packager
6877
```
6978

7079
#### Python 2.7

entrypoint.sh

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,48 @@ set -e
33

44
if [ `whoami` == "root" ]; then
55

6-
if [ "$RUNTIME" == "node4" ]; then
7-
echo "Setting node to v4"
8-
rm /usr/local/bin/node /usr/local/bin/npm
9-
ln -s /opt/node-v${NODE_VERSION_4}-linux-x64/bin/node /usr/local/bin/node
10-
ln -s /opt/node-v${NODE_VERSION_4}-linux-x64/bin/npm /usr/local/bin/npm
6+
if [ "$RUNTIME" == "" ]; then
7+
echo "Using default runtime node v8"
118
fi
129

10+
if [ "$RUNTIME" == "node" ]; then
11+
echo "Using default node v8 runtime"
12+
fi
13+
1314
if [ "$RUNTIME" == "node6" ]; then
14-
echo "Setting node to v6"
15+
echo "Setting node runtime to v6"
1516
rm /usr/local/bin/node /usr/local/bin/npm
16-
ln -s /opt/node-v${NODE_VERSION_6}-linux-x64/bin/node /usr/local/bin/node
17-
ln -s /opt/node-v${NODE_VERSION_6}-linux-x64/bin/npm /usr/local/bin/npm
17+
ln -sf /opt/node-v${NODE_VERSION_6}-linux-x64/bin/node /usr/local/bin/node
18+
ln -sf /opt/node-v${NODE_VERSION_6}-linux-x64/bin/npm /usr/local/bin/npm
19+
fi
20+
21+
if [ "$RUNTIME" == "node8" ]; then
22+
echo "Setting node runtime to v8"
23+
rm /usr/local/bin/node /usr/local/bin/npm
24+
ln -sf /opt/node-v${NODE_VERSION_8}-linux-x64/bin/node /usr/local/bin/node
25+
ln -sf /opt/node-v${NODE_VERSION_8}-linux-x64/bin/npm /usr/local/bin/npm
26+
fi
27+
28+
if [ "$RUNTIME" == "python" ]; then
29+
echo "Using default python v2 runtime"
30+
ln -sf /usr/bin/python2.7 /usr/bin/python2
31+
fi
32+
33+
if [ "$RUNTIME" == "python2" ]; then
34+
echo "Setting python runtime to 2"
35+
ln -sf /usr/bin/python2.7 /usr/bin/python2
36+
fi
37+
38+
if [ "$RUNTIME" == "python3.6" ]; then
39+
echo "Setting python runtime to 3.6"
40+
ln -sf /opt/python-${PYTHON_VERSION_3_6}/bin/python3 /usr/bin/python3
41+
ln -sf f/opt/python-${PYTHON_VERSION_3_6}/bin/pip3 /usr/bin/pip3
42+
fi
43+
44+
if [ "$RUNTIME" == "python3.7" ]; then
45+
echo "Setting python runtime to 3.7"
46+
ln -sf /opt/python-${PYTHON_VERSION_3_7}/bin/python3 /usr/bin/python3
47+
ln -sf /opt/python-${PYTHON_VERSION_3_7}/bin/pip3 /usr/bin/pip3
1848
fi
1949

2050
if [ "$HOST_UID" != "" ]; then

0 commit comments

Comments
 (0)