Install node.js and PostgreSQL
Clone repo then install packages using the command npm install
Using PostgreSQL, Create DB for NB with a user that has full access to it. Helpful resource.
Add a config file for your database called config.js in the base folder of the project structured like below. Entries in config db should match the ones you used in Postgres:
var config = {
db: {
name: 'YOUR_DB_NAME',
user: 'YOUR_DB_USERNAME',
pass: 'YOUR_DB_PASSWORD'
}
}
module.exports = config;
Create a .env file with the following content and place it in the base folder of the project (where config.js is).
JWT_SECRET=ENTER-SECRET-HERE-(RANDOM-STRING)
defaults write com.apple.finder AppleShowAllFiles -bool YES
killall Finder
Run NB in separate terminals
npm run dev
npm run serve
Access UI on https://127.0.0.1:8080/
SSH to the server ssh -i [YOUR_KEY].key [USER]@[HOST].csail.mit.edu
Install NodeJS
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - sudo apt-get install -y nodejs
Helpful resource.
Install PM2 sudo npm install -g pm2
Helpful resource.
Follow steps 1 & 2 from Local Dev (see above).
Configure HTTPS on the server:
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot
$ sudo certbot certonly --manual
.well-known
, inside .well-know create another folder and name it acme-challenge
.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]
/etc/letsencrypt/live/[yourname]-nb.csail.mit.edu
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)
To generate UI bundle, run npm run build
.
If you are runing npm v7
or above, run sudo chown root .
.
To start NB, run the following command sudo pm2 start --node-args="--max-old-space-size=16384" npm --name "NB" --time -- start
.
To make PM2 run automatically after reboot, run the following command sudo pm2 startup
then run sudo pm2 save
.
You should be able to access NB using [HOST].csail.mit.edu
.
Redirect HTTP to HTTPS as follow
sudo apt install nginx
.sudo ufw allow 'Nginx HTTP'
./etc/nginx/sites-enabled/default
and add return 301 https://$host$request_uri;
under server_name
.sudo systemctl reload nginx
. 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
to update certificate, run sudo certbot renew
, if this doesn't work try certbot certonly --manual -d $DOMAIN.com
then recreate the challange.