Shipmight

Step-by-step tutorial

Deploy NodeJS+Postgres with persistent data

Prerequisites

This tutorial assumes a fresh install of Shipmight.

Outline

These are the steps we’ll go through:

  1. Create a persistent volume for Postgres
  2. Create and deploy Postgres application
  3. Create and deploy NodeJS application
  4. Publish the application at a specific port

Create a persistent volume for Postgres

In order to persist our Postgres data, we will first create a volume on the disk. In Shipmight a volume is simply a folder in a specific location.

Navigate to Volumes, where you will see an empty list because we haven’t created any volumes yet.

Screenshot of Volumes

Click Add volume.

Screenshot of New Volume -page

For Name, type in a unique name for this volume. In this tutorial we’ll use “postgres-data”.

Screenshot of filled form

Click Create volume. You will now see the created volume in the list.

Screenshot of Volumes

Create and deploy Postgres application

In Shipmight you can deploy any image from Docker Hub. In this tutorial we’ll make use of the official postgres-image.

Navigate to Applications, where you’ll see an empty list because we haven’t created any applications yet.

Screenshot of Applications

Click New application and fill in the following details:

Also add a volume mount:

The form should look something like this:

Screenshot of filled form

Note that Enable rolling deployments is left unchecked. It is only suitable for HTTP-based services, which Postgres isn’t.

When ready, click Create application. You will be redirected to the newly created application.

Screenshot of Application

The application isn’t yet deployed. In order to deploy, we’ll specify a docker tag which will be pulled from Docker Hub. In this tutorial we want to pull the latest Postgres version, so we’ll type in “latest”. After typing in the tag and clicking Deploy, you will see a new deployment in the list:

Screenshot of deployment list

We can see that the deployment status is Created. Click View logs to view the deployment progress in real-time.

Screenshot of Deployment

The deployment may take a minute or two because it will pull the whole postgres image from Docker Hub. In future deployments layers of the image will be re-used, making for faster downloads.

Wait until the deployment is ready.

Screenshot of Deployment ready

You can go to Logs to verify that the container is up and running, and is accepting connections.

Screenshot of Logs

Create and deploy NodeJS application

Back in Applications, click New application to create another application.

Fill in the following details:

Also we'll provide the Postgres connection string to the application. Add it as a new environment variable, which the application will use:

The form should look something like this:

Screenshot of filled form

When ready, click Create application. You will be redirected to the newly created application.

The application isn’t yet deployed. In order to deploy, we’ll specify a git branch which will be pulled from the git repository. In this tutorial we want to pull from postgres-demo, so we’ll type in “postgres-demo”. After typing in the branch and clicking Deploy, you will see a new deployment in the list:

Screenshot of deployment list

We can see that the deployment status is Created. Click View logs to view the deployment progress in real-time.

When deploying your application for the first time, it may take a bit longer to pull the initial code because the whole git repository is cloned to the server. In future deployments the repository will already be there and only changes will be pulled, so it will be faster.

Wait until the deployment is ready.

Screenshot of Deployment ready

You can go to Logs to verify that the container is up and running, and our application has started.

Screenshot of Logs

Publish the application at a specific port

The easiest way to publish the application to the outside internet is via a public port.

Back in Applications, click Network from the top navigation.

Screenshot of Network

Click Add public port and fill in the following details:

The form should look something like this:

Screenshot of filled form

Click Create public port. You will now see the public port in the list.

Screenshot of Network

Wait until Nginx status has updated to up-to-date.

Then you can access the application at http://[your_server_ip]:8000:

Screenshot of application in browser

All done!


Back to home

Shipmight is a self-hosted PaaS. Read more.


Enter your email address for updates:

@shipmight on Twitter

No spam. Just Shipmight news.