I'll use DigitalOcean to deploy Cezerin. My droplet :
- Choose an image:
Ubuntu 18.04.1 x64
- Choose a size:
1 GB (RAM), 1 vCPU, 25 GB (SSD)
We need to install:
-
Docker
18.06.0-ce
We'll use Docker to run MongoDB in container. You may not need it.
-
Nginx
1.14.0
apt update && apt install nginx-full
-
Node
v8.11.3
-
Update NPM
6.3.0
npm i -g npm
-
PM2
3.0.3
npm i -g pm2
docker run --name store-db -d -p 27017:27017 -v /var/www/store-db:/data/db mongo:latest
-
Clone a Git repository
cd /var/www git clone https://github.com/cezerin/cezerin
-
Change setting
cd cezerin/config mv admin.production.js admin.js mv store.production.js store.js mv server.production.js server.js
Open
server.js
and change-
SMTP server
smtpServer: { host: '', port: 0, secure: true, user: '', pass: '', fromName: '', fromAddress: '' },
-
Generate new values for secret keys
// key to sign tokens jwtSecretKey: '...', // key to sign store cookies cookieSecretKey: '...',
Save file and go back to root app directory.
cd ../
-
-
Install dependencies
npm i
-
Build project
npm run build
-
Prepare database At this step our database is empty. To add default data, indexes and access token we need to run:
npm run setup <email> <domain>
I don't have domain, so I'll use my server ip:
npm run setup [email protected] https://142.93.0.0
This script will add token with email [email protected] and set my doman to https://142.93.0.0
-
Start an application
pm2 start process.json
At this step, we have 2 applications (api and store) running on port 3001 and 3000.
We need to add a new website to Nginx.
-
Change Nginx config file
cd /etc/nginx/sites-available
open
default
file and paste this config -
Reload Nginx configuration
nginx -t && service nginx reload
At this step, I have my website on https://142.93.0.0. I can go to the dashboard on https://142.93.0.0/admin with email: [email protected]. SMTP server from config/server.js
will send me an email with a link to sign in.
Next steps:
- Setup domain
- Setup HTTPS with CloudFlare or Let's Encrypt
- Secure a MongoDB
- Configure a Firewall