Prerequisites

Before you begin, make sure you have the following installed on your system:

  • Docker Engine (20.10.0 or higher)
  • Docker Compose (v2.0.0 or higher)
  • OpenSSL (for generating SSL certificates)

Installing Docker

For macOS:

  1. Download and install Docker Desktop from Docker Hub
  2. Follow the installation wizard
  3. Verify installation:
docker --version
docker-compose --version

For Linux (Ubuntu/Debian):

# Update package index
sudo apt-get update

# Install prerequisites
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Set up stable repository
echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# Add your user to docker group
sudo usermod -aG docker $USER

For Windows:

  1. Download and install Docker Desktop from Docker Hub
  2. Enable WSL 2 following Docker’s documentation
  3. Follow the installation wizard
  4. Verify installation in PowerShell:
docker --version
docker-compose --version

Step 1: Create Project Directory

Create a new directory for your CaseBender deployment and navigate into it:

mkdir casebender-deployment
cd casebender-deployment

Step 2: Configure Environment Variables

Create a .env file with the following content:

# Authentication
AUTH_SECRET="B7OawnWf6+LwB/9yXbxbk4ppZ1khydqj4qc9k9g3nnE="
AUTH_SALT="B7OawnW"
NEXTAUTH_URL=https://local.casebender.com
NEXTAPP_URL=https://local.casebender.com

# Liveblocks Configuration
LIVEBLOCKS_SECRET_KEY=sk_dev_HaIczPV4gPit5_gx7YRsNXLGJNzBE5wQ8z8I1H8ft3ZPZHVrfH2ryJJ586ezHYla

# Database Configuration
POSTGRES_PRISMA_URL="postgresql://superadmin:88AlwaysTimeToWin88@db:5432/casebender?pgbouncer=true&connect_timeout=15"
POSTGRES_URL="postgresql://superadmin:88AlwaysTimeToWin88@db:5432/casebender?pgbouncer=true&connect_timeout=15"
POSTGRES_URL_NON_POOLING="postgresql://superadmin:88AlwaysTimeToWin88@db:5432/casebender"

# Redis Configuration
REDIS_URL="redis://redis:6379"

Step 3: Generate SSL Certificates

For local development, generate self-signed SSL certificates:

# Generate SSL certificate and key
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout local-casebender.key \
  -out local-casebender.crt \
  -subj "/CN=local.casebender.com/O=CaseBender/C=US"

# Verify the certificate
openssl x509 -in local-casebender.crt -text -noout

Step 4: Configure Nginx

Create nginx.conf with the following content:

events {
    worker_connections 1024;
}

http {
    server {
        listen 443 ssl http2;
        server_name local.casebender.com;

        ssl_certificate /etc/nginx/certs/local-casebender.crt;
        ssl_certificate_key /etc/nginx/certs/local-casebender.key;

        location / {
            proxy_pass http://app: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;
        }
    }

    # Optional HTTP server to redirect to HTTPS
    server {
        listen 80;
        server_name local.casebender.com;
        # Redirect all HTTP traffic to HTTPS
        return 301 https://$host$request_uri;
    }
}

Step 5: Create Docker Compose Configuration

Create docker-compose.yml with the following content:

services:
  app:
    ports:
      - "3000:3000"
    environment:
      - AUTH_SECRET=${AUTH_SECRET}
      - AUTH_SALT=${AUTH_SALT}
      - NEXTAUTH_URL=${NEXTAUTH_URL:-https://local.casebender.com}
      - NEXTAPP_URL=${NEXTAPP_URL:-https://local.casebender.com}
      - LIVEBLOCKS_SECRET_KEY=${LIVEBLOCKS_SECRET_KEY}
      - POSTGRES_PRISMA_URL=${POSTGRES_PRISMA_URL}
      - POSTGRES_URL=${POSTGRES_URL}
      - POSTGRES_URL_NON_POOLING=${POSTGRES_URL_NON_POOLING}
    image: casebender/casebender:latest
    depends_on:
      - db
    restart: unless-stopped

  db:
    image: postgres
    environment:
      POSTGRES_USER: superadmin
      POSTGRES_PASSWORD: 88AlwaysTimeToWin88
      POSTGRES_DB: casebender
    ports:
      - "5433:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data

  workflow-processor:
    image: casebender/workflow-processor:latest
    environment:
      - POSTGRES_PRISMA_URL=${POSTGRES_PRISMA_URL}
      - POSTGRES_URL=${POSTGRES_URL}
      - POSTGRES_URL_NON_POOLING=${POSTGRES_URL_NON_POOLING}
      - REDIS_URL=${REDIS_URL}
    depends_on:
      - db
      - redis
    ports:
      - "3001:3001"

  misp-processor:
    image: casebender/misp-processor:latest
    environment:
      - POSTGRES_PRISMA_URL=${POSTGRES_PRISMA_URL}
      - POSTGRES_URL=${POSTGRES_URL}
      - POSTGRES_URL_NON_POOLING=${POSTGRES_URL_NON_POOLING}
      - REDIS_URL=${REDIS_URL}
    depends_on:
      - db
      - redis
    ports:
      - "3002:3002"

  redis:
    image: redis:7.2-alpine
    command: redis-server --protected-mode no
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    restart: unless-stopped

  minio:
    image: quay.io/minio/minio
    mem_limit: 512m
    command: ["minio", "server", "/data", "--console-address", ":9090"]
    environment:
      - MINIO_ROOT_USER=minioadmin
      - MINIO_ROOT_PASSWORD=minioadmin
    ports:
      - "9090:9090"
      - "9000:9000"
    volumes:
      - "miniodata:/data"

  nginx:
    image: nginx:latest
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./local-casebender.crt:/etc/nginx/certs/local-casebender.crt:ro
      - ./local-casebender.key:/etc/nginx/certs/local-casebender.key:ro
    depends_on:
      - app

volumes:
  miniodata:
  pgdata:
  redis_data:

Step 6: Configure Local DNS

Add the following entry to your hosts file:

For macOS and Linux:

sudo echo "127.0.0.1 local.casebender.com" >> /etc/hosts

For Windows:

Add the following line to C:\Windows\System32\drivers\etc\hosts:

127.0.0.1 local.casebender.com

Step 7: Start the Application

  1. Pull the required images:
docker-compose pull
  1. Start all services:
docker-compose up -d
  1. Monitor the logs:
docker-compose logs -f
  1. Access the application at https://local.casebender.com

Troubleshooting

Common Issues

  1. Certificate Warnings:

    • The browser will show a security warning because we’re using a self-signed certificate
    • Click “Advanced” and proceed to the website
    • For development purposes, this is expected and safe
  2. Port Conflicts:

    • Ensure ports 80, 443, 3000-3002, 5433, 6379, 9000, and 9090 are not in use
    • If needed, modify the port mappings in docker-compose.yml
  3. Database Connection:

    • Check PostgreSQL logs: docker-compose logs db
    • Verify database credentials in .env
    • Ensure the database is running: docker-compose ps db
  4. Service Dependencies:

    • If services fail to start, check their dependencies:
    docker-compose ps
    docker-compose logs [service_name]
    

Checking Logs

View logs for specific services:

# All services
docker-compose logs

# Specific service
docker-compose logs [service_name]

# Follow logs
docker-compose logs -f [service_name]

Service Management

# Restart a specific service
docker-compose restart [service_name]

# Stop all services
docker-compose down

# Remove volumes (will delete all data)
docker-compose down -v

Next Steps

Now that you have CaseBender running locally, you might want to: