Production Deployment

This guide walks through deploying the eTeamups Platform to a production server using Docker Compose. It also covers the alternative PM2-based deployment approach.

Prerequisites

  • Operating System: Ubuntu 22.04 or later
  • Docker: Docker Engine with Docker Compose v2 plugin
  • RAM: Minimum 2 GB (4 GB recommended)
  • Git: For cloning the repository
  • GHCR Access: GitHub personal access token with read:packages scope

Step-by-Step Deployment

1. Clone the Repository

git clone https://github.com/creativeaura/eteamups-platform.git
cd eteamups-platform

2. Configure Environment Variables

Copy the example environment file and update it with production values:

cp docker.local.env docker.env

Open docker.env and update the following critical variables:

Variable Description
MONGODB_URI MongoDB connection string with credentials
REDIS_PASSWORD Strong password for the Redis instance
JWT_SECRET Random secret for signing JSON Web Tokens
RESEND_API_KEY API key for the Resend email service
BASE_URL Public-facing URL of the platform
CORS_ORIGIN Allowed CORS origins (comma-separated)

All default and placeholder values must be replaced with production-appropriate secrets before starting services.

3. Set Up SSL Certificates

Place your SSL certificates in the Nginx SSL directory:

mkdir -p nginx/ssl
cp /path/to/fullchain.pem nginx/ssl/fullchain.pem
cp /path/to/privkey.pem nginx/ssl/privkey.pem

For testing or staging environments, generate self-signed certificates:

./scripts/generate-ssl.sh

4. Authenticate with GHCR

echo "<GITHUB_PERSONAL_ACCESS_TOKEN>" | docker login ghcr.io -u <GITHUB_USERNAME> --password-stdin

5. Pull Docker Images

docker compose pull

6. Start Infrastructure Services

Start MongoDB and Redis first and wait for their health checks to pass:

docker compose up -d mongodb redis

Verify they are healthy:

docker compose ps

Both services should show a status of healthy before proceeding.

7. Seed the Database (Fresh Install Only)

If this is a new deployment, seed the database with initial data:

./scripts/seed-docker.sh

Skip this step when updating an existing deployment.

8. Create Log Directory

mkdir -p logs

9. Start All Services

docker compose up -d

10. Verify Deployment

Run the health check script to confirm all services are running:

./scripts/health-check.sh

Updating an Existing Deployment

Full Update

Pull the latest images and restart all services:

docker compose pull
docker compose up -d

Individual Service Update (Zero-Downtime)

Update a single service without restarting others:

docker compose pull auth-service
docker compose up -d --no-deps auth-service

The --no-deps flag prevents dependent services from being restarted.

Resource Limits

Each Node.js service is configured with a memory limit to prevent any single service from consuming excessive resources:

NODE_OPTIONS=--max-old-space-size=512

This limits each service to 512 MB of heap memory. Adjust this value in docker.env if your server has more available RAM.

PM2 Alternative Deployment

For environments where Docker is not available or not preferred, PM2 can manage the Node.js processes directly.

Build the Project

Compile TypeScript to JavaScript:

npm install
npm run build

Start with PM2

pm2 start ecosystem.config.js

The ecosystem.config.js file defines all services, their entry points, environment variables, and resource limits.

PM2 Management Scripts

Script Description
scripts/start.sh Build and start all services
scripts/stop.sh Stop all running services

PM2 Useful Commands

# View running processes
pm2 list

# View logs for a specific service
pm2 logs auth-service

# Restart a specific service
pm2 restart auth-service

# Monitor all services
pm2 monit

When using PM2, MongoDB and Redis must be installed and running on the host or accessible via network. They are not managed by PM2.