Creating a NodeJS application container

RSS

Creating a NodeJS application container

Last updated June 8th, 2016

When creating a NodeJS container there are a few ways to go about it, depending on your application and needs.

In this article we will cover setting up a standalone NodeJS application with custom ports. We will also talk about using an Nginx proxy to handle web assets, images and resources when your NodeJS application is used as a web service.

  1. Navigate to the 'Containers' module. If you're about to create your very first container, you should see a message similar to the one shown below. Click the 'Add Container' button in the upper right corner of the page to get started:

    No containers

  2. Select the 'Service' tab, then choose the 'NodeJS' option. You can additionally change the name of your container on this page, for now we will leave this as 'nodejs44'.

    Service Selection

  3. On the next step you will be presented with some additional options that you wouldn't normally see when creating a regular web container. In this example we will be adding an SSH/SFTP user, an additional port, as well as changing the containers entrypoint.

    3.1. Adding a SSH/SFTP user. SSH

    3.2. Publishing Ports

    By default all containers can connect to a NodeJS container on port 8080, if you need to publish a port so it is accessible directly from a remote location, you can enter up to five (5) ports here. Select Ports

    3.3. Custom Entrypoint

    By default all NodeJS containers will try and look for the file '/container/application/app.js'. If your NodeJS application file is named differently or in another location, you can change this here. Select Entrypoint

  4. Once the container has been started, simply upload your application and restart the container. Restarting the container is required in order for node to automatically start your application.

Logs for your application can be found in the following locations:

  1. /container/application/logs/supervisor/nodejs-stdout.log
  2. /container/application/logs/supervisor/nodejs-stderr.log

Nginx Proxy

If your NodeJS application is used as a web application, you may need a proxy in front to handle static assets, images and other resources.

You can create an nginx proxy just like any other web container.

At the time of writing, when creating an Nginx proxy it is already configured to connect to a NodeJS container named 'nodejs44'. If for some reason you changed your container name, or you want to use the proxy for other another use, you will need to edit the default nginx configuration to suit your needs.

Can we improve this article? Suggest an improvement to this article.

Suggest an Improvement

Thank you for helping us to improve this Knowledge Base article. Please type your suggestions below:

Still need help? Get in touch with us.

If you aren't able to find the help you need then please send us a question and we can help you further.