🚀 Deployment Guide

Deploy OpenCodeHub to your preferred platform. Choose Docker for simplicity, Vercel for serverless, or VPS for full control.

📋 Deployment Options

Platform Difficulty Best For Estimated Time
🐳 Docker Easy Quick setup, self-hosted 5-10 minutes
▲ Vercel Easy Serverless, auto-scaling 10-15 minutes
🖥️ VPS Medium Full control, bare metal 30-45 minutes

🐳 Docker Deployment

The fastest way to get OpenCodeHub running. Includes PostgreSQL and all dependencies.

💡 Prerequisites

Docker 20.10+ and Docker Compose installed on your system.

Clone the Repository
$ git clone https://github.com/swadhinbiswas/OpencodeHub.git && cd OpenCodeHub
Configure Environment

Copy the example environment file and configure your secrets:

$ cp .env.example .env

Generate secure secrets for production:

# Generate secrets (copy these to your .env file)
openssl rand -hex 32  # For JWT_SECRET
openssl rand -hex 32  # For SESSION_SECRET
openssl rand -hex 32  # For INTERNAL_HOOK_SECRET
Start Services
$ docker-compose up -d

This starts PostgreSQL and the OpenCodeHub application.

Create Admin User
$ docker-compose exec app bun run scripts/seed-admin.ts

Follow the prompts to create your administrator account.

Access Your Instance

Open http://localhost:3000 in your browser and log in with your admin credentials.

📁 Docker Compose Configuration

version: '3.8'
services:
  app:
    build: .
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=postgresql://postgres:password@db:5432/opencodehub
      - NODE_ENV=production
    depends_on:
      - db
    volumes:
      - ./repos:/app/repos
      - ./data:/app/data

  db:
    image: postgres:15-alpine
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=opencodehub
    volumes:
      - postgres_data:/var/lib/postgresql/data

volumes:
  postgres_data:

▲ Vercel Deployment

Deploy OpenCodeHub as a serverless application with automatic scaling.

⚠️ Important Note

Git repository storage requires external storage (S3, R2, etc.) when using Vercel.

Fork the Repository

Fork OpenCodeHub on GitHub to your account.

Import to Vercel

Go to vercel.com/new and import your forked repository.

Configure Environment Variables

Add the following environment variables in Vercel project settings:

Variable Description
DATABASE_URL PostgreSQL connection string (use Vercel Postgres or external)
JWT_SECRET 32+ character secret for JWT tokens
SESSION_SECRET 32+ character secret for sessions
SITE_URL Your Vercel deployment URL
STORAGE_TYPE Set to s3 for cloud storage
Deploy

Click "Deploy" and wait for the build to complete. Your instance will be available at your Vercel URL.

🖥️ VPS / Linux Deployment

Full control deployment on any Linux server with systemd and Nginx.

💡 Recommended Specs

2+ CPU cores, 4GB+ RAM, 50GB+ SSD. Ubuntu 22.04 or Debian 12 recommended.

Install Dependencies
# Update system
sudo apt update && sudo apt upgrade -y

# Install Node.js 20
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install -y nodejs

# Install PostgreSQL
sudo apt install -y postgresql postgresql-contrib

# Install Git and Nginx
sudo apt install -y git nginx certbot python3-certbot-nginx
Setup PostgreSQL
# Create database and user
sudo -u postgres psql

CREATE USER opencodehub WITH PASSWORD 'your-secure-password';
CREATE DATABASE opencodehub OWNER opencodehub;
GRANT ALL PRIVILEGES ON DATABASE opencodehub TO opencodehub;
\q
Clone and Configure
# Clone repository
cd /opt
sudo git clone https://github.com/swadhinbiswas/OpencodeHub.git
cd OpenCodeHub

# Install dependencies
sudo npm install

# Configure environment
sudo cp .env.example .env
sudo nano .env  # Edit with your production values

# Run migrations
sudo npm run db:push

# Build for production
sudo npm run build
Create Systemd Service
# Create service file
sudo nano /etc/systemd/system/opencodehub.service
[Unit]
Description=OpenCodeHub
After=network.target postgresql.service

[Service]
Type=simple
User=www-data
WorkingDirectory=/opt/OpenCodeHub
ExecStart=/usr/bin/node dist/server/entry.mjs
Restart=on-failure
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target
# Enable and start service
sudo systemctl enable opencodehub
sudo systemctl start opencodehub
Configure Nginx
# Create Nginx config
sudo nano /etc/nginx/sites-available/opencodehub
server {
    listen 80;
    server_name git.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_cache_bypass $http_upgrade;
    }
}
# Enable site
sudo ln -s /etc/nginx/sites-available/opencodehub /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

🔐 SSL Certificate Setup

Secure your OpenCodeHub instance with HTTPS using Let's Encrypt.

Install Certbot
$ sudo apt install certbot python3-certbot-nginx
Obtain Certificate
$ sudo certbot --nginx -d git.yourdomain.com

Follow the prompts. Certbot will automatically configure Nginx for HTTPS.

Auto-Renewal

Certbot automatically sets up certificate renewal. Test it with:

$ sudo certbot renew --dry-run

✅ Production Checklist

Before Going Live

  • ✅ Set strong secrets (JWT_SECRET, SESSION_SECRET, INTERNAL_HOOK_SECRET)
  • ✅ Configure HTTPS with valid SSL certificate
  • ✅ Set correct SITE_URL in environment
  • ✅ Enable rate limiting (RATE_LIMIT_SKIP_DEV=false)
  • ✅ Enable CSRF protection (CSRF_SKIP_DEV=false)
  • ✅ Configure database backups
  • ✅ Set up monitoring and alerts
  • ✅ Create admin account with 2FA