Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.
This repository was archived by the owner on Jun 11, 2020. It is now read-only.

Use docker_file to build node_modules and acquire additional libraries #6

@salrashid123

Description

@salrashid123

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_tmp

To 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/execer

To 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions