Skip to content

Commit e9fdd85

Browse files
authored
Merge pull request #8 from myrmex-org/update_runtimes
Update runtimes
2 parents 6790298 + 5293e3f commit e9fdd85

File tree

4 files changed

+54
-39
lines changed

4 files changed

+54
-39
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

cmd.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
set -e
33

4-
if [ "$RUNTIME" == "python" ] || [ "$RUNTIME" == "python2" ]; then
4+
if [ "$RUNTIME" == "python" ] || [ "$RUNTIME" == "python2" ] || [ "$RUNTIME" == "python2.7" ]; then
55
su $DEFAULT_USER -c "pip install --requirement requirements.txt --upgrade --target ."
6-
elif [ "$RUNTIME" == "python3" ]; then
6+
elif [ "$RUNTIME" == "python3" ] || [ "$RUNTIME" == "python3.6" ] || [ "$RUNTIME" == "python3.7" ]; then
77
su $DEFAULT_USER -c "pip3 install --requirement requirements.txt --upgrade --target ."
88
else
99
su $DEFAULT_USER -c "npm install --production"

entrypoint.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
set -e
33

44
if [ `whoami` == "root" ]; then
5-
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
11-
fi
12-
13-
if [ "$RUNTIME" == "node6" ]; then
14-
echo "Setting node to v6"
5+
if [ "$RUNTIME" == "python" ] || [ "$RUNTIME" == "python2" ] || [ "$RUNTIME" == "python2.7" ]; then
6+
echo "Using python v2.7 runtime"
7+
elif [ "$RUNTIME" == "python3" ] || [ "$RUNTIME" == "python3.7" ]; then
8+
echo "Using python v3.7 runtime"
9+
elif [ "$RUNTIME" == "python3.6" ]; then
10+
echo "Using python v3.6 runtime"
11+
ln -sf /opt/python-${PYTHON_VERSION_3_6}/bin/python3 /usr/bin/python3
12+
ln -sf /opt/python-${PYTHON_VERSION_3_6}/bin/pip3 /usr/bin/pip3
13+
elif [ "$RUNTIME" == "node6" ]; then
14+
echo "Using node v6 runtime"
1515
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
16+
ln -sf /opt/node-v${NODE_VERSION_6}-linux-x64/bin/node /usr/local/bin/node
17+
ln -sf /opt/node-v${NODE_VERSION_6}-linux-x64/bin/npm /usr/local/bin/npm
18+
else
19+
echo "Using node v8 runtime"
1820
fi
1921

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

0 commit comments

Comments
 (0)