Skip to content

Deploy on Coolify

Difficulty: Easy | Time: 20 minutes | Method: Docker Compose (Git-based)

Coolify is an open-source, self-hosted alternative to Heroku, Netlify, and Render. It makes deploying OpenCodeHub incredibly simple with built-in SSL, automatic deployments, and managed databases.


  • A server (VPS) with Ubuntu 22.04/24.04, Debian 12, or CentOS 9
  • Minimum 2 CPU cores, 4GB RAM, 40GB SSD
  • A domain name pointed to your server (e.g., git.yourdomain.com)
  • Coolify v4 installed on your server

If you haven’t installed Coolify yet, run this on your server:

Terminal window
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash

After installation:

  1. Open http://your-server-ip:8000
  2. Complete the onboarding wizard
  3. Set up your domain (e.g., coolify.yourdomain.com)

  1. In Coolify dashboard, click ProjectsAdd
  2. Name it OpenCodeHub
  3. Select your server and environment (e.g., production)
  1. Go to your project → ResourcesAdd New ResourceDatabase
  2. Select PostgreSQL
  3. Configuration:
    Name: opencodehub-postgres
    Version: 16
    Database: opencodehub
    Username: opencodehub
    Password: <generate-strong-password>
  4. Click Start
  5. Note down the internal connection string (e.g., postgresql://opencodehub:password@opencodehub-postgres:5432/opencodehub)
  1. Add New ResourceDatabaseRedis
  2. Configuration:
    Name: opencodehub-redis
    Version: 7-alpine
    Password: <generate-strong-password>
  3. Click Start
  4. Note down the internal URL (e.g., redis://:password@opencodehub-redis:6379)

  1. Go to your project → ResourcesAdd New ResourceApplication
  2. Select Public Repository
  3. Repository URL: https://github.com/swadhinbiswas/OpencodeHub.git
  4. Branch: main
  5. Build Pack: Docker Compose
  6. Click Continue

Coolify will auto-detect the docker-compose.yml. You need to customize it for Coolify’s environment:

Replace the detected compose with this Coolify-optimized version:

services:
app:
build:
context: .
dockerfile: Dockerfile
container_name: opencodehub
restart: unless-stopped
ports:
- "4321:4321"
environment:
- NODE_ENV=production
- DATABASE_URL=${DATABASE_URL}
- REDIS_URL=${REDIS_URL}
- JWT_SECRET=${JWT_SECRET}
- SESSION_SECRET=${SESSION_SECRET}
- INTERNAL_HOOK_SECRET=${INTERNAL_HOOK_SECRET}
- CRON_SECRET=${CRON_SECRET}
- RUNNER_SECRET=${RUNNER_SECRET}
- WORKFLOW_SECRET_ENCRYPTION_KEY=${WORKFLOW_SECRET_ENCRYPTION_KEY}
- SITE_URL=${COOLIFY_FQDN:-http://localhost:4321}
- SSH_HOST_KEY_PATH=/data/ssh/host_key
- STORAGE_TYPE=local
- STORAGE_PATH=/data/storage
- REPOS_PATH=/data/repos
volumes:
- opencodehub-repos:/data/repos
- opencodehub-storage:/data/storage
- opencodehub-ssh:/data/ssh
- opencodehub-cache:/data/cache
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:4321/api/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 15s
volumes:
opencodehub-repos:
opencodehub-storage:
opencodehub-ssh:
opencodehub-cache:

In Coolify, go to your app → Environment Variables and add:

VariableValueDescription
DATABASE_URLpostgresql://opencodehub:YOUR_PASS@opencodehub-postgres:5432/opencodehubFrom Step 2.2
REDIS_URLredis://:YOUR_PASS@opencodehub-redis:6379From Step 2.3
JWT_SECRETopenssl rand -hex 32Generate this
SESSION_SECRETopenssl rand -hex 32Generate this
INTERNAL_HOOK_SECRETopenssl rand -hex 32Generate this
CRON_SECRETopenssl rand -hex 32Generate this
RUNNER_SECRETopenssl rand -hex 32Generate this
WORKFLOW_SECRET_ENCRYPTION_KEYopenssl rand -hex 32Generate this
SITE_URLhttps://git.yourdomain.comYour domain
COOLIFY_FQDNLeave as-is (auto-set)Coolify injects this

Security Tip: Use Coolify’s “Secret” toggle for all *_SECRET variables so they are encrypted at rest.

In your app settings → Persistent Storage, verify these volumes are created:

Volume NameContainer PathPurpose
opencodehub-repos/data/reposGit repositories
opencodehub-storage/data/storageFile uploads
opencodehub-ssh/data/sshSSH host keys
opencodehub-cache/data/cacheApplication cache

  1. In your app → SettingsDomains
  2. Add your domain: git.yourdomain.com
  3. Coolify will automatically configure the reverse proxy
  1. Go to SettingsSSL/TLS
  2. Select Let’s Encrypt (Auto)
  3. Enable HTTPS Redirect
  4. Click Save

Coolify handles:

  • Nginx reverse proxy
  • SSL certificate generation and renewal
  • WebSocket support
  • Gzip compression

  1. Click Deploy
  2. Coolify will:
    • Clone the repository
    • Build the Docker image
    • Start the container
    • Run health checks
  3. Wait for the “Healthy” status

Run the seed script inside the container:

Terminal window
# In Coolify dashboard, go to your app → "Execute Command" or use terminal
docker exec -it opencodehub bun run scripts/seed-admin.ts

Or via Coolify’s web terminal:

  1. Go to your app → Terminal
  2. Run: bun run scripts/seed-admin.ts
  3. Enter username, email, and password when prompted

Visit https://git.yourdomain.com and log in with the admin credentials.

Test the API health endpoint:

Terminal window
curl https://git.yourdomain.com/api/health

If you want to run CI/CD pipelines:

  1. Go to your project → ResourcesAdd New Resource
  2. Select Docker ComposeExisting Docker Compose
  3. Add the runner service to your compose:
runner:
build:
context: .
dockerfile: Dockerfile.runner
container_name: opencodehub-runner
restart: unless-stopped
privileged: true
environment:
- RUNNER_TOKEN=${RUNNER_TOKEN}
- SERVER_URL=https://git.yourdomain.com
- DOCKER_HOST=unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- runner-work:/work
- runner-cache:/cache
volumes:
runner-work:
runner-cache:
  1. Get the runner token from OpenCodeHub admin panel → Runners → Register Runner
  2. Add RUNNER_TOKEN to environment variables
  3. Deploy the updated compose

Step 8: Automated Deployments (GitHub Integration)

Section titled “Step 8: Automated Deployments (GitHub Integration)”
  1. In Coolify, go to your app → SettingsGit
  2. Enable Auto Deploy on Push
  3. Coolify will automatically rebuild and redeploy on every push to main

For pull request previews:

  1. Go to SettingsPreview Deployments
  2. Enable Pull Request Previews
  3. Each PR will get a unique URL like pr-123.git.yourdomain.com

Coolify has built-in backup for databases. To back up volumes:

Terminal window
# On your server
docker run --rm -v opencodehub-repos:/data -v $(pwd):/backup alpine tar czf /backup/repos-backup.tar.gz -C /data .
docker run --rm -v opencodehub-storage:/data -v $(pwd):/backup alpine tar czf /backup/storage-backup.tar.gz -C /data .
  1. Push new code to your fork/main branch
  2. Coolify auto-deploys, OR
  3. In Coolify dashboard → your app → Deploy

In Coolify dashboard:

  • Go to your app → Logs
  • Real-time logs with filtering
  • Access historical logs

ProblemSolution
Build fails with “ConnectionRefused”Retry the build; bun registry might be temporarily unavailable. The Dockerfile has built-in retry logic.
App shows “502 Bad Gateway”Wait 2-3 minutes for first startup. Check logs for database connection errors.
Database connection errorVerify DATABASE_URL uses the internal Coolify service name (e.g., opencodehub-postgres).
Storage not persistingCheck that persistent volumes are mounted correctly in Coolify storage settings.
SSL not workingEnsure your domain DNS points to the Coolify server. Check Coolify’s SSL logs.
Git push over SSH failsEnsure port 2222 is exposed and not blocked by firewall. Map it in Coolify: 2222:2222.

Internet
|
v
Cloudflare (optional)
|
v
Coolify Server
|-- Coolify Proxy (Nginx + SSL)
|-- OpenCodeHub App (Docker)
| |-- Port 4321: Web UI + API
| |-- Port 2222: SSH Git
|-- PostgreSQL (managed)
|-- Redis (managed)
|-- OpenCodeHub Runner (optional, privileged Docker)