Skip to content

Latest commit

 

History

History
136 lines (85 loc) · 3.48 KB

PRODUCTION.md

File metadata and controls

136 lines (85 loc) · 3.48 KB

1. Requirements

This tutorial assumes you are using Ubuntu 18.04 or newer.

It will follow this structure:

https://mydomain.com/            // Web
https://admin.mydomain.com/      // Administration panel
https://api.mydomain.com/        // API server
  1. Copy and paste ReaderFront files under /var/www/readerfront/
  2. NodeJS 13 or newer.
  3. MariaDB and create a Database
  4. NGINX
  5. A Domain with the follow subdomains: api and admin

2. Configure the settings

Before proceeding, there are some settings you will need to configure. To configure them, copy the .env.example files to .env and edit them on every project. Remember to modify:

NODE_ENV=development
APP_URL=http://localhost:3000/
API_URL=http://localhost:8000/

REACT_APP_APP_URL=http://localhost:3000
REACT_APP_READER_PATH=http://localhost:8000

to

NODE_ENV=production
APP_URL=https://mydomain.com/
API_URL=https://api.mydomain.com/

REACT_APP_APP_URL=https://mydomain.com
REACT_APP_READER_PATH=https://api.mydomain.com

3. Install the dependencies

yarn install

4. Build Projects

Build project run:

yarn build:all

4. Migrate database

To migrate database and create the schema run:

yarn db:migrate

5. Daemonize Applications

PM2 is a process manager for Node.js applications. PM2 makes it possible to daemonize applications so that they will run in the background as a service.

Use npm to install the latest version of PM2 on your server:

yarn global add pm2

The -g option tells npm to install the module globally, so that it’s available system-wide.

Daemonize api:

pm2 start yarn --name "readerfront-api" -- prod:api

Check that the API is running at http://YOUR_SERVER_IP:8000/

Daemonize web:

pm2 start yarn --name "readerfront-web" -- prod:web

Check that the API is running at http://YOUR_SERVER_IP:3000/

Serve admin static file and reverse proxy

Your application is running and listening on localhost, but you need to set up a way for your users to access it. We will set up the Nginx web server as a reverse proxy for this purpose.

Configure NGINX to serve admin static files and reverse proxy api and web. Using this tool you should have a similar configuration like this:

Web

alt text

alt text

Api

alt text

alt text

Admin

alt text

alt text

Configure Nginx

Follow the Setup and Files steps to configure Nginx and SSL (with certbot).

Serve admin static files

To move the static files to nginx run:

mv /var/www/readerfront/admin/build/* /var/www/admin.mydomain.com/
sudo systemctl reload nginx

remember to rename the domain name

Create admin account

To create the admin account go to https://admin.mydomain.com/auth/signup and the account will be automatically activated. Then you can login https://admin.mydomain.com/auth/login.