Installation [ Old ]

All the steps required to deploy Nesula on a node app server

Note: we will be using Linux user 'ifactory' with DNS entries for nesula.ifactory.co and www.nesul... to ths server.

1. Pre-Steps

  • Have a Node Server prebuilt - see the other setup docs.

2. Create Folder

$ mkdir /var/www/nesula.ifactory.co
$ cd /var/www/nesula.ifactory.co

3. Install Nesula Repository

$ git init
$ git clone https://github.com/iFactoryDigital/Nesula.git  [ When prompted enter Github username & password ]

New Github Clone Method

  1. Create an SSH Key and add to your account. Note Github.com only excepts OpenSSH key's. To convert your PuttyGen my-ssh-key.pub ceate a new file my-ssh-key.open-ssh.pub and add the following:

ssh-rsa   
  1. TBC - SSH is too much bother while clone https:// still functions

4. Download Dependencies

NestJS Dependencies

Angular Dependencies

6. Database and ORM Config

  1. If you are using Postgres on this server then ensure a staging or production database has been created e.g. 'nesula_stage'

  2. Rename the existing ormconfig.json to ormconfig-dev.json

  3. Create a new ormconfig.json for the stage/prod environment and update with correct host, username, password and database.

5. Build App

7. Setup Virtual Hosts

Paste in the Nginx configuration

Then confirm Ngin config and restart

5. Install SSL Cetificate

This assumes Certbot is already installed and firewall allows HTTPS. See Hello.js node setup document for more.

6. Serve the App

Change the working directory to run commands:

Run in Staging 'stage' with Node

Ensure this line is in the nest-api package.json:

To start the app in stage:

Run In Production 'prod' with PM2

Ensure this line is in the nest-api package.json:

To serve app in prod:

7. Monitor App Performance - OPTIONAL

8. Environment Variables, config & NODE_ENV

It is import to correctly set the NODE_ENV environment variable.

Nesula makes use of the NestJS ConfigModule and ConfigService. ConfigService imports the following config files:

The configuraiton.ts file values can either be populated by values from the .env file or if they are not environment specific hard coded directly.

Environment variables are available in configuration.ts as follows:

Nesula has four config files:

Set config file for environment

To deploy a config file in a particular environment we replace the .env file. For Example in production:

To simplify this deployment step we have created the following commands:

We can also manually set the process.env.NODE_ENV from the server environment variable at run time

To set NODE_ENV at the command line:

9. Check DNS & Reverse DNS Settings

Last updated

Was this helpful?