Skip to main content

Setup Guide

Table of Contents

Overview

This guide provides step-by-step instructions for deploying the Rhea frontend application on Digital Ocean. The deployment uses PM2 for process management and Nginx as a reverse proxy server.

Deployment Process

1. Clone the Repository

git clone git@github.com:Rhea-Africa/Rhea-Frontend.git rhea-frontend
cd rhea-frontend

2. Install Dependencies

yarn install

3. Build the Production Version

yarn build

Process Management

1. Install PM2

PM2 is a production process manager for Node.js applications that helps keep applications alive and running.

npm install -g pm2

2. Start the Application with PM2

pm2 start "PORT=3000 yarn start" --name rhea_frontend

3. Configure PM2 to Start on System Boot

This ensures your application automatically restarts if the server reboots.

pm2 startup

Follow the instructions provided by PM2 to complete the setup.

4. Save the PM2 Process List

pm2 save

Web Server Configuration

1. Create Nginx Configuration

Create a new Nginx configuration file for the frontend:

sudo nano /etc/nginx/sites-available/rhea_main_frontend

2. Add Server Configuration

Paste the following configuration, adjusting domain names if necessary:

server {
listen 80;
server_name rhea.africa www.rhea.africa;

location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
}
}

3. Enable the Configuration

Create a symbolic link to enable the site:

sudo ln -s /etc/nginx/sites-available/rhea_main_frontend /etc/nginx/sites-enabled/

4. Test and Restart Nginx

sudo nginx -t
sudo systemctl restart nginx

SSL Configuration

Secure the Site with Let's Encrypt

Install Certbot and obtain SSL certificates:

sudo certbot --nginx

Follow the interactive prompts to select your domains and configure HTTPS settings.

Environment Variables

Encrypting Environment Variables

Important: Ensure there are no blank lines in your .env file to avoid decryption issues.

sops --encrypt --age '<public-key>' .prod.env > secret.env

Monitoring and Maintenance

View Application Logs

pm2 logs rhea_frontend

Monitor Application Status

pm2 status

Restart the Application

pm2 restart rhea_frontend