Running GovReady CMS API Server on Ubuntu - GovReady/GovReady-CMS-API GitHub Wiki
GovReady CMS-API runs as Software as a Service on a server at https://plugin.govready.com managed by GovReady PBC.
Depending on your network setup and security requirements, you may prefer to run and connect your dashboard to your own GovReady CMS-API server. The following are instructions for installing GovReady CMS-API server on Ubuntu.
Install nvm and node
Commands to run to setup Ubuntu 14.04 / 16.04 server:
# Install node via nvm
apt-get update
apt-get install git
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
# Follow terminal instruction to restart terminal to start nvm (e.g., logout and log in)
nvm install 6
node -v
npm install -g forever
Install python (for Let's Encrypt)
apt-get install python
Install mongodb
# Ubuntu 16.04 has a different key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
# Ubuntu 14.04 has a different key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
service mongod status
Create /etc/systemd/system/mongodb.service with the below content:
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target
[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf
[Install]
WantedBy=multi-user.target
Start mongodb and create database and user
- follow instructions from https://scalegrid.io/blog/getting-started-with-user-management-in-mongodb/
- Reference: https://docs.mongodb.com/manual/tutorial/manage-users-and-roles/)
service mongod start
# create database and users
mongo
> use govready-cms-api
> db.createUser({'user':'govready', 'pwd':'passwordhere', roles:['readWrite']})
> show users
> exit
# test login
mongo -u 'govready' -p 'passwordhere' localhost/govready-cms-api
Install and run GovReady-CMS-API
cd /var/local
git clone https://github.com/GovReady/GovReady-Agent-Client.git
git clone https://github.com/GovReady/GovReady-CMS-API.git
cd GovReady-CMS-API
npm install
mv public public.bak
ln -s /var/local/GovReady-Agent-Client/dist/ /var/local/GovReady-CMS-API/public
Configuring the API Service
Copy .env.example to .env, and complete the details.
cp .env.example .env
# edit .env with appropriate values, such as mongodb database user credentials
The GovReady API uses Auth0 for authentication, so you will need to create an account (free accounts are available and fully-functional). If you are adding a server to a GovReady subdomain (for example (plugin.govready.com)[https://plugin.govready.com]) there should be no Auth0 configuration tweaks necessary. Otherwise you will need to login to the Auth0 Dashboard and add your domain to the (Allowed Origins (CORS))[https://manage.auth0.com/#/clients/HbYZO5QXKfgNshjKlhZGizskiaJH9kGH/settings] field.
Running the API Service
# Run in foreground
node ./bin/www
# Run in background
forever start ./bin/www