Skip to content

Latest commit

 

History

History
137 lines (111 loc) · 3.24 KB

how-to-deploy-a-cezerin-on-ubuntu-18-04-1-github.md

File metadata and controls

137 lines (111 loc) · 3.24 KB

How to deploy a Cezerin on Ubuntu 18.04.1 (from GitHub)

1. Requirements

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:

  1. Docker 18.06.0-ce

    Get Docker CE for Ubuntu

    We'll use Docker to run MongoDB in container. You may not need it.

  2. Nginx 1.14.0

    apt update && apt install nginx-full
  3. Node v8.11.3

    Installing Node.js via package manager

  4. Update NPM 6.3.0

    npm i -g npm
    
  5. PM2 3.0.3

    npm i -g pm2
    

2. Run MongoDB

docker run --name store-db -d -p 27017:27017 -v /var/www/store-db:/data/db mongo:latest

3. Run Cezerin

  1. Clone a Git repository

    cd /var/www
    git clone https://github.com/cezerin/cezerin
  2. 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 ../
    
  3. Install dependencies

    npm i
    
  4. Build project

    npm run build
    
  5. 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

  6. Start an application

    pm2 start process.json
    

    At this step, we have 2 applications (api and store) running on port 3001 and 3000.

4. Run Nginx

We need to add a new website to Nginx.

  1. Change Nginx config file

    cd /etc/nginx/sites-available
    

    open default file and paste this config

  2. Reload Nginx configuration

    nginx -t && service nginx reload
    

4. What's next

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:

  1. Setup domain
  2. Setup HTTPS with CloudFlare or Let's Encrypt
  3. Secure a MongoDB
  4. Configure a Firewall