Code Monkey home page Code Monkey logo

faas-js-runtime-image's Introduction

FaaS Node.js Runtime Image CircleCI

This image is meant to run in an OpenShift cluster with Knative installed. It is currently under development and incomplete. When a container for this image starts, a process loads the JavaScript in /home/node/usr on the container file system. If there is a package.json file in the directory, the bootstrap process will run npm install before loading the function.

Source to Image

This image may also be used as a source to image builder.

Limitations

  • The image currently responds to HTTP requests on port 8080 and to Knative Events, which users can consume as CloudEvent object.
  • The function is passed a Context object when it is called. This object currently contains little to no valuable information beyond the Node.js http.IncomingMessage (the request), http.ServerResponse objects and cloudevent object, which is instantiated if the function responds to incoming Knative Event.

Surely there are other limitations, but this is enough for plenty of discussion at the moment.

Building

To build the image, run the following command.

make build

You should end up with an image at redhat-faas/js-runtime.

Running locally

You can run this image locally to play around with it, test edges and generally get a feel for how it works. First, create a directory containing one or more JavaScript files. One of these must be named index.js. The bootstrap process will load this file and any other files it references via module dependencies (e.g. const myCalc = require('./my-calc.js');). If you have external, third party dependencies from npmjs.com, add a package.json to the directory specifying the dependencies.

With the source in place, you can start the container and mount the source onto a container directory. The bootstrap process expects /home/node/usr to contain the runtime source code. To mount this into a running container execute the following command.

docker run --rm -a stdout -a stderr -v /path/to/local/source/dir:/home/node/usr -p 8080:8080 oscf/js-runtime:candidate

To stop the running container:

$ docker ps
$ docker stop <CONTAINER ID>

Testing

To test the image, run the following command.

make test

This will build a candidate image, and mount the ./test directory on the host to the /home/node/usr directory on the running container. When the container starts, a bootstrap process loads the test JavaScript in /home/node/usr.

faas-js-runtime-image's People

Contributors

danbev avatar lance avatar lholmquist avatar slinkydeveloper avatar zroubalik avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.