A Node.js application must fulfill several requirements before it can run successfully on VIP’s infrastructure. The Node.js skeleton starter repository includes example applications that fulfill all of these requirements.
Health check endpoint
All Node.js applications must implement the health check endpoint using application code. The VIP Platform sends frequent health checks at this endpoint:
VIP uses the dependencies and scripts defined in
package.json to install, build, and start an application. Make sure all necessary packages needed for an application to run are publicly accessible and are added as
dependencies and not
Only production dependencies are installed:
npm install --production
build script allows a Node.js application to be compiled or perform any necessary tasks before being started. Even if an app does not require a build step, it is still expected that this script to be present. Use
"build": "echo 'No build'" or equivalent to fulfill this requirement. The
build script must complete successfully (exit with
npm run build
After a successful build, VIP will start an app using the
start script. Not all frameworks supply a
start script, so Node.js applications must define one manually.
VIP assigns a dynamic port to applications using the
PORT environment variable. An application needs to start on the assigned port to work correctly.
If an application’s port is declared in code, use
process.env.PORT to access the assigned port. Add logic to fall back to a default port if no port is assigned (i.e., in local development):
const PORT = process.env.PORT || 3000;
If an application’s port is defined in the
start script in
package.json, access the assigned port using
"start": "frontity serve --port $PORT"
Stateless, immutable, and multi-container
All Node.js applications on VIP must be able to run across multiple containers and processes simultaneously. This means that each deployment of a Node.js application must be stateless and immutable. An application must not rely on absolute paths.
The file system in the container is read-only. Files can be stored temporarily in a temp directory. Instead of hardcoding
/tmp/ to access those files, use
If any data is stored in memory, it will be lost on deployment or when containers are added or removed.
Data can be persisted elsewhere (e.g., in a WordPress application via the REST API or GraphQL). If cache data is needed for later reuse, Redis can be deployed alongside the Node.js application.
Last updated: December 23, 2023