Skip to content

How to Deploy Managem with Docker and Docker Compose

  • by

This guide explains how to deploy Managem using Docker Compose and PostgreSQL on a remote Linux server.

Docker packages the Managem application and its dependencies into containers, simplifying deployment and updates.

Prerequisites

Before deploying Managem, make sure your server has:

  • Docker Engine 24 or newer
  • Docker Compose v2 or newer
  • At least 1 GB of free disk space
  • SSH access
  • A domain name for production use

Step 1 — Install Docker

Install Docker:

curl -fsSL https://get.docker.com | sh

Add your user to the Docker group:

sudo usermod -aG docker $USER

Apply the group change:

newgrp docker

Verify Docker:

docker --version

Step 2 — Download Managem

Clone the Managem repository:

git clone https://github.com/your-org/managem.git /opt/managem

Enter the Managem server directory:

cd /opt/managem/server

Step 3 — Configure Managem Secrets

Create the Managem environment file:

nano .env

Add:

NODE_ENV=production
PORT=5000
JWT_SECRET=replace_with_a_long_random_secret
FRONTEND_URL=https://yourdomain.com

POSTGRES_DB=managem
POSTGRES_USER=managem
POSTGRES_PASSWORD=a_strong_password

DATABASE_URL=postgresql://managem:a_strong_password@postgres:5432/managem

STRIPE_SECRET_KEY=sk_live_xxx
GOOGLE_CLIENT_ID=your_google_client_id
GITHUB_CLIENT_ID=your_github_client_id

Never commit the Managem .env file to Git.

Step 4 — Build the Managem Frontend

On your local machine or CI server, build the React frontend:

cd client
npm install
npm run build

Copy the production files into the Managem server public directory:

cp -r dist/* ../server/public/

You can also clone the complete Managem repository on the remote server and perform the frontend build there.

Step 5 — Start Managem with PostgreSQL

Navigate to the Managem server directory:

cd /opt/managem/server

Start the PostgreSQL deployment:

docker compose --profile postgres up --build -d

Docker Compose will:

  • Pull the PostgreSQL image
  • Build the Managem application image
  • Connect Managem to the PostgreSQL container
  • Persist PostgreSQL data in a named Docker volume

Step 6 — Use an Alternative Database

Managem can also be deployed with MySQL:

docker compose --profile mysql up --build -d

For a lightweight single-node deployment, use SQLite:

docker compose --profile sqlite up --build -d

Choose the database configuration appropriate for your Managem installation.

Step 7 — Seed the Managem Database

Run:

docker compose exec app node seed.js

This initializes the Managem database with the required application data.

Step 8 — Verify Managem

Check the running containers:

docker compose ps

Test the Managem health endpoint:

curl http://localhost:5000/api/health

A successful response should look similar to:

{"status":"ok"}

Open the Managem application at:

http://your-server-ip:5000

Step 9 — Enable HTTPS for Managem

For production, install Nginx and Certbot:

sudo apt install -y nginx certbot python3-certbot-nginx

Create an SSL certificate:

sudo certbot --nginx -d yourdomain.com

Configure Nginx to proxy traffic to the Managem container on port 5000:

location / {
    proxy_pass http://127.0.0.1:5000;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Step 10 — Update Managem

Pull the latest Managem source:

git pull origin main

Build the latest frontend:

cd client
npm run build
cp -r dist/* ../server/public/

Return to the server directory:

cd ../server

Rebuild and restart Managem:

docker compose --profile postgres up --build -d

The PostgreSQL data remains persisted while the Managem application is rebuilt and updated.