Skip to content

20rohanc/nb

 
 

Repository files navigation

Installation

Local Dev

  1. clone repo then install packages using the command npm install

  2. Install PostgreSQL and Create DB for NB with a user that has full access to it. Helpful resource.

  3. Add a config file for your database called config.js structured like below:

var config = {
  db: {
    name: 'YOUR_DB_NAME',
    user: 'YOUR_DB_USERNAME',
    pass: 'YOUR_DB_PASSWORD'
  }
}
module.exports = config;
  1. Add email-config.js file in thr root of the project like below (you can use your gmail account or ask admin for test account):
const nodemailer = require("nodemailer");
const transporter = nodemailer.createTransport({
  service: 'gmail',
  auth: { 
    user: 'EMAIL_ADDRESS',
    pass: 'EMAIL_PASSWORD'
  }
});
module.exports = transporter;
  1. Create .env file with the following content
JWT_SECRET=ENTER-SECRET-HERE-(RANDOM-STRING)
  1. Run NB in separate terminals

    • Run backend using command npm run dev
    • run UI using command npm run serve
  2. Access UI on https://127.0.0.1:8080/ . Note: Since we're using a self generated certificate for development, the browser will alert that you are running an insecure server. In Chrome type: thisisunsafe.

Deploy NB (Production)

  1. SSH to the server ssh -i [YOUR_KEY].key [USER]@[HOST].csail.mit.edu

  2. Install NodeJS curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs Helpful resource.

  3. Install PM2 sudo npm install -g pm2 Helpful resource.

  4. Follow steps 1 & 2 from Local Dev (see above).

  5. Configure HTTPS on the server:

    • Install certbot
    $ sudo add-apt-repository ppa:certbot/certbot
    $ sudo apt-get update
    $ sudo apt-get install certbot
    
    • Generate an SSL certificate with certbot $ sudo certbot certonly --manual
    • Part of the certbot configuration, type your domain name without the protocol part. For instance: yourname-nb.csail.mit.edu.
    • When asked "Are you ok with your IP being logged?", type Y then ENTER.
    • Open a new connection to the server on a new terminal, don't close the previous one.
    • In the new terminal, navigate to the nb projecat and inside the public folder create a folder and name it .well-known, inside .well-know create another folder and name it acme-challenge.
    • In the directory acme-challenge, create an empty file and name it as instructed from the certbot in the first terminal.
    • Paste the challenge from the certbot into the file created in the previous step.
    • Run the nb server using sudo npm run http, and verify that you can access the challenge on the URL http://[yourname]-nb.csail.mit.edu/.well-known/acme-challenge/[challenge file name]
    • If everything is okay, go back to the first terminal and type ENTER.
    • Finally, you will find all the files that you need under this path /etc/letsencrypt/live/[yourname]-nb.csail.mit.edu

Helpful resource.

  1. Create .env file with the following content
SSL_KEY=PATH_TO/privkey.pem
SSL_CERT=PATH_TO/cert.pem
SSL_CA=PATH_TO/chain.pem
PORT=443
JWT_SECRET=ENTER-SECRET-HERE-(RANDOM-STRING)
  1. To generate UI bundle, run npm run build.

  2. To start NB, run the following command sudo pm2 start npm --name "NB" --time -- start.

  3. To make PM2 run automatically after reboot, run the following command sudo pm2 startup then run sudo pm2 save.

  4. You should be able to access NB using [HOST].csail.mit.edu.

Useful PM2 Commands

sudo pm2 list                   # list all processes
sudo pm2 reload <ID|NAME|all>   # reload after changes to the code
sudo pm2 del <ID|NAME>          # delete process by id or name
sudo pm2 log < |NAME>           # show log for all or by name
sudo pm2 log all                # show all logs

Other

to update certificate, run sudo certbot renew, if this doesn't work try certbot certonly --manual -d $DOMAIN.com then recreate the challange.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 50.0%
  • Vue 45.4%
  • HTML 3.6%
  • CSS 1.0%