-
Notifications
You must be signed in to change notification settings - Fork 41
Use docker_file to build node_modules and acquire additional libraries #6
Description
This is a longer term FR:
At the moment, the build and test steps requires gcc,make nodejs. However, those are only needed if you want to deploy with functions.zip or run the test node server.
Suggestion is two part:
allow users to run cloud function alone locally using native toolchains and not deal with node and the execv.
The advantage of this is you don't need node, make, gcc or anything and can elect to acquire them during deployment by other means.
By other means i mean like build node_modules and execve entirely in docker and then "copy" them to your workstation just prior to creating functions.zip.
This would require the runtime binary to accept both sockets as arguments as well as listen on its own (eg:)
http.ListenAndServe(":8080", nil)The following dockerfile is an example of this 'just in time' library/module support:
Makefile
all: node_modules lib bin_from_local
zip -FS -r $(OUT) bin/ lib/ node_modules index.js package.json -x *build*
bin_from_local:
<use go to compile ./main into bin/>
node_modules:
docker build -t docker_tmp -f dockerfiles/Dockerfile_node_modules .
docker cp `docker create docker_tmp`:/user_code/node_modules .
docker rmi -f docker_tmp
lib:
docker build -t docker_tmp -f dockerfiles/Dockerfile_lib .
docker cp `docker create docker_tmp`:/user_code/lib .
docker rmi -f docker_tmpTo compile node_modules:
Dockerfile_node_modules
FROM debian:jessie
ADD . /user_code
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
gcc \
npm \
build-essential \
&& rm -rf /var/lib/apt/lists/*
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
apt-get update && apt-get install -y nodejs
WORKDIR /user_code
RUN npm install --save local_modules/execerTo acquire additional shared objects (.so) files and copy them to lib/
FROM debian:jessie
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
libc6 \
libcurl3 \
libgcc1 \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /user_code/lib && \
for i in `dpkg -L libc6 libcurl3 libgcc1 | egrep "^/usr/lib/x86_64-linux-gnu/.*\.so\."`; do cp $i /user_code/lib; done