From d0ad377d727e671fa18a02f956e69a1e4fc79813 Mon Sep 17 00:00:00 2001 From: Soam Vasani Date: Wed, 8 Feb 2017 16:43:19 -0800 Subject: [PATCH] Add README to NodeJS env --- environments/nodejs/README.md | 45 +++++++++++++++++++++++++++++++++++ environments/nodejs/server.js | 6 +++++ 2 files changed, 51 insertions(+) create mode 100644 environments/nodejs/README.md diff --git a/environments/nodejs/README.md b/environments/nodejs/README.md new file mode 100644 index 00000000..afbe3bfa --- /dev/null +++ b/environments/nodejs/README.md @@ -0,0 +1,45 @@ +# Fission: NodeJS Environment + +This is the NodeJS environment for Fission. + +It's a Docker image containing a NodeJS runtime, along with a dynamic +loader. A few common dependencies are included in the package.json +file. + +## Customizing this image + +To add package dependencies, edit package.json to add what you need, +and rebuild this image (instructions below). + +You also may want to customize what's available to the function in its +request context. You can do this by editing `server.js` (see the +comment in that file about customizing request context). + +## Rebuilding and pushing the image + +You'll need access to a Docker registry to push the image: you can +sign up for Docker hub at hub.docker.com, or use registries from +gcr.io, quay.io, etc. Let's assume you're using a docker hub account +called USER. Build and push the image to the the registry: + +``` + docker build -t USER/nodejs-env . && docker push USER/nodejs-env +``` + +## Using the image in fission + +You can add this customized image to fission with "fission env +create": + +``` + fission env create --name nodejs --image USER/nodejs-env +``` + +Or, if you already have an environment, you can update its image: + +``` + fission env update --name nodejs --image USER/nodejs-env +``` + +After this, fission functions that have the env parameter set to the +same environment name as this command will use this environment. diff --git a/environments/nodejs/server.js b/environments/nodejs/server.js index d40fb4e5..4b3d83f0 100644 --- a/environments/nodejs/server.js +++ b/environments/nodejs/server.js @@ -80,6 +80,12 @@ app.all('/', function (req, res) { res.status(status).send(body); } try { + // + // Customizing the request context + // + // If you want to modify the context to add anything to it, + // you can do that here by adding properties to the context. + // userFunction(context, callback); } catch(e) { console.log(`Function error: ${e}`);