Environment variables

When core starts a Docker container it sets some environment variables. The variables contain runtime information specific to the application or spacelet running inside it.

Variable Description
IS_REAL_SPACEIFY Applications and spacelets can be developed without actually installing them to the edge node. This way they do not need to run inside a sandboxed Docker container but directly on the edge computer. This environment variable can used to determine whether the application is running inside a container or is it running directly on the edge. See the debugging subsection of application development for more information about this subject.
NODE_PATH The global path where Node.js finds the core api modules (/api/node_modules).
PORT_x The internal ports Docker has mapped to external ports, where x is the internal ports number. The ports from 2777 onwards are unsecure ports and from 3777 onwards secure ports. The webservers ports are in PORT_80 and PORT_443.

The port numbers can be acquired In Node.js using the global process object.

var httpPort = process.env["PORT_80"]; 
var httpsPort = process.env["PORT_443"]; 
var firstServicePort = process.env["PORT_2777"];
var firstServiceSecurePort = process.env["PORT_3777"];

The value of the variable httpPort might be 32711 and firstServicePort 32709 depending how the ports were mapped during the start of a Docker container.

copyright © 2014