Skip to content

Latest commit

 

History

History
161 lines (119 loc) · 3.86 KB

File metadata and controls

161 lines (119 loc) · 3.86 KB

Contabo Server Setup Guide

This guide provides instructions for deploying Compass on a Contabo server using Docker.

Prerequisites

  • Contabo VPS with Ubuntu/Debian
  • Docker and Docker Compose installed
  • Domain configured with DNS pointing to your server
  • SSH access to the server

Initial Server Setup

  1. Update system packages:
sudo apt update && sudo apt upgrade -y
  1. Install Docker:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
  1. Install Docker Compose:
sudo apt install docker-compose -y

Deploy Compass

  1. Clone the repository:
git clone https://github.com/Merge-Labs/Compass.git
cd Compass/nisria-backend
  1. Configure environment variables:
cp env.prod.example .env.prod
nano .env.prod  # Edit with your production settings

Key variables to configure in .env.prod:

  • SECRET_KEY: Generate a secure Django secret key
  • DATABASE_NAME, DATABASE_USER, DATABASE_PASSWORD: Your PostgreSQL credentials
  • ALLOWED_HOSTS: Your domain names (e.g., example.com,api.example.com)
  • DEBUG: Should be False in production
  • GUNICORN_WORKERS: Number of Gunicorn workers (typically 2-4)
  1. Build and run the containers:
docker-compose -f docker-compose.prod.yml up --build -d

Creating the First Super Admin

After deploying for the first time, you need to create a super admin user:

docker-compose -f docker-compose.prod.yml exec web python manage.py createsuperuser

You will be prompted to enter:

  • Email address
  • Username
  • Password
  • Password confirmation

This account will have full administrative access to the Compass system.

Running Migrations

If needed, run database migrations:

docker-compose -f docker-compose.prod.yml exec web python manage.py migrate

Collecting Static Files

To collect static files for Django admin:

docker-compose -f docker-compose.prod.yml exec web python manage.py collectstatic --noinput

SSL/TLS Configuration

Set up SSL certificates using Certbot (replace with your actual domain):

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d example.com -d api.example.com

Replace example.com with your actual domain name.

Monitoring Logs

View application logs:

docker-compose -f docker-compose.prod.yml logs -f web

View nginx logs:

docker-compose -f docker-compose.prod.yml logs -f nginx

Updating the Application

To update to the latest version:

cd Compass
git pull origin main
cd nisria-backend
docker-compose -f docker-compose.prod.yml down
docker-compose -f docker-compose.prod.yml up --build -d

Backup Database

Create a database backup:

# Using variables from your docker-compose.prod.yml configuration
# Replace DB_USER and DB_NAME with values from your .env.prod file
docker-compose -f docker-compose.prod.yml exec -T db pg_dump -U <DB_USER> <DB_NAME> > backup_$(date +%Y%m%d).sql

Example with default values:

docker-compose -f docker-compose.prod.yml exec -T db pg_dump -U manassehgitau main > backup_$(date +%Y%m%d).sql

Note: The -T flag disables pseudo-TTY allocation for proper output redirection. Replace <DB_USER> and <DB_NAME> with your actual database credentials from docker-compose.prod.yml.

Troubleshooting

Container not starting

docker-compose -f docker-compose.prod.yml logs web

Database connection issues

Check if the database container is running:

docker-compose -f docker-compose.prod.yml ps

Permission issues

Ensure proper permissions on the docker-entrypoint.sh:

chmod +x docker-entrypoint.sh

Additional Resources