Skip to content

Installation

sonsoleslp edited this page May 3, 2022 · 6 revisions

Dependencies

sudo apt install git-all
  • Install node (10.x.x) with npm.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt update
sudo apt -y install nodejs
  • Install postgres or any other supported DB (MySQL, MariaDB, SQLite and Microsoft SQL Server).
sudo apt-get update
sudo apt-get install postgresql postgresql-contrib

External services

Download and install Escapp

  • Clone this repository:
git clone http://github.com/ging/escapp
cd escapp
  • Install code dependencies:
npm install
  • Create user and database:
sudo -i -u postgres
psql
create database escapp_prod;
create user loguser with encrypted password 'xxxxxx';
grant all privileges on database escapp_prod to loguser;
\q
exit
  • Create database tables:
npm run migrate_local
  • [ Optional ] Seed database (only in development):
npm run seed_local
  • Configure environment variables in .env file:
DATABASE_URL=postgres://xxxxxx@localhost/escapp_prod
CLOUDINARY_URL=...
SENDGRID_API_KEY=...
APP_NAME=myserverurl.com
PORT=80
HTTPS_PRIVATE_KEY=/etc/ssl/private/key.pem
HTTPS_CERTIFICATE=/etc/ssl/certs/cert.pem
HTTPS_CA_CERT=/etc/ssl/certs/DigiCertCA.pem
  • Run the server in development mode
npm run dev

Deploy to production

  • Save SSL certificates in or change the corresponding paths in the .env file:
/etc/ssl/private/key.pem
/etc/ssl/certs/cert.pem
/etc/ssl/certs/DigiCertCA.pem
  • Set the NODE_ENV environment variable to production:
export NODE_ENV=production
  • Run the server:
npm run start_production
  • [ Optional ] Install pm2 and run the server with it:
sudo npm install -g pm2
sudo npm run start_production_pm2

## Update escapp to the latest version

cd escapp
git pull origin master
npm install
npm run migrate_local
sudo pm2 stop 0
sudo npm run start_production_pm2