/ opencodehub / public / docs / deployment.html
swadhinbiswas # Changelog Β· 1/17/2026
9eabb75
533 lines Β· 23.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Deployment Guide - OpenCodeHub Docs</title>
    <meta name="description"
        content="Complete deployment guide for OpenCodeHub - Docker, Vercel, VPS deployment tutorials">
    <link rel="icon" type="image/svg+xml" href="../public/logo.svg">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap"
        rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
</head>

<body>
    <!-- Header -->
    <header class="header">
        <a href="index.html" class="header-logo">
            <img src="../public/logo.svg" alt="OpenCodeHub" height="40">
        </a>
        <nav class="header-nav">
            <a href="getting-started.html">Getting Started</a>
            <a href="deployment.html">Deployment</a>
            <a href="cli.html">CLI</a>
            <a href="api.html">API</a>
            <a href="https://github.com/swadhinbiswas/OpencodeHub" class="btn-github" target="_blank">
                <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
                    <path
                        d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
                </svg>
                GitHub
            </a>
        </nav>
    </header>

    <div class="layout">
        <!-- Sidebar -->
        <aside class="sidebar">
            <div class="sidebar-section">
                <div class="sidebar-title">Getting Started</div>
                <nav class="sidebar-nav">
                    <a href="getting-started.html" class="sidebar-link">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" />
                        </svg>
                        Quick Start
                    </a>
                </nav>
            </div>

            <div class="sidebar-section">
                <div class="sidebar-title">Deployment</div>
                <nav class="sidebar-nav">
                    <a href="deployment.html" class="sidebar-link active">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <rect x="2" y="3" width="20" height="14" rx="2" ry="2" />
                            <path d="M8 21h8M12 17v4" />
                        </svg>
                        Overview
                    </a>
                    <a href="#docker" class="sidebar-link">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <path
                                d="M22 12.5c0 .5-.5 1-1 1h-2v-2h2c.5 0 1 .5 1 1zM2 12.5c0-.5.5-1 1-1h2v2H3c-.5 0-1-.5-1-1z" />
                            <rect x="6" y="9" width="12" height="6" rx="1" />
                        </svg>
                        Docker
                    </a>
                    <a href="#vercel" class="sidebar-link">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <polygon points="12 2 2 22 22 22" />
                        </svg>
                        Vercel
                    </a>
                    <a href="#vps" class="sidebar-link">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <rect x="2" y="2" width="20" height="8" rx="2" ry="2" />
                            <rect x="2" y="14" width="20" height="8" rx="2" ry="2" />
                            <line x1="6" y1="6" x2="6.01" y2="6" />
                            <line x1="6" y1="18" x2="6.01" y2="18" />
                        </svg>
                        VPS / Linux
                    </a>
                    <a href="#ssl" class="sidebar-link">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <rect x="3" y="11" width="18" height="11" rx="2" ry="2" />
                            <path d="M7 11V7a5 5 0 0110 0v4" />
                        </svg>
                        SSL Setup
                    </a>
                </nav>
            </div>

            <div class="sidebar-section">
                <div class="sidebar-title">CLI</div>
                <nav class="sidebar-nav">
                    <a href="cli.html" class="sidebar-link">
                        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                            <polyline points="4 17 10 11 4 5" />
                            <line x1="12" y1="19" x2="20" y2="19" />
                        </svg>
                        CLI Reference
                    </a>
                </nav>
            </div>
        </aside>

        <!-- Main Content -->
        <main class="main">
            <div class="content">
                <h1>πŸš€ Deployment Guide</h1>
                <p>
                    Deploy OpenCodeHub to your preferred platform. Choose Docker for simplicity,
                    Vercel for serverless, or VPS for full control.
                </p>

                <!-- Overview -->
                <section>
                    <h2>πŸ“‹ Deployment Options</h2>

                    <table>
                        <thead>
                            <tr>
                                <th>Platform</th>
                                <th>Difficulty</th>
                                <th>Best For</th>
                                <th>Estimated Time</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td><strong>🐳 Docker</strong></td>
                                <td><span class="badge badge-primary">Easy</span></td>
                                <td>Quick setup, self-hosted</td>
                                <td>5-10 minutes</td>
                            </tr>
                            <tr>
                                <td><strong>β–² Vercel</strong></td>
                                <td><span class="badge badge-primary">Easy</span></td>
                                <td>Serverless, auto-scaling</td>
                                <td>10-15 minutes</td>
                            </tr>
                            <tr>
                                <td><strong>πŸ–₯️ VPS</strong></td>
                                <td><span class="badge">Medium</span></td>
                                <td>Full control, bare metal</td>
                                <td>30-45 minutes</td>
                            </tr>
                        </tbody>
                    </table>
                </section>

                <!-- Docker -->
                <section id="docker">
                    <h2>🐳 Docker Deployment</h2>
                    <p>The fastest way to get OpenCodeHub running. Includes PostgreSQL and all dependencies.</p>

                    <div class="alert alert-info">
                        <div class="alert-title">πŸ’‘ Prerequisites</div>
                        <p>Docker 20.10+ and Docker Compose installed on your system.</p>
                    </div>

                    <div class="steps">
                        <div class="step">
                            <div class="step-title">Clone the Repository</div>
                            <div class="step-content">
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">git clone
                                        https://github.com/swadhinbiswas/OpencodeHub.git && cd OpenCodeHub</span>
                                </div>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Configure Environment</div>
                            <div class="step-content">
                                <p>Copy the example environment file and configure your secrets:</p>
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">cp .env.example .env</span>
                                </div>
                                <p>Generate secure secrets for production:</p>
                                <pre><code># 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</code></pre>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Start Services</div>
                            <div class="step-content">
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">docker-compose up -d</span>
                                </div>
                                <p>This starts PostgreSQL and the OpenCodeHub application.</p>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Create Admin User</div>
                            <div class="step-content">
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">docker-compose exec app bun run
                                        scripts/seed-admin.ts</span>
                                </div>
                                <p>Follow the prompts to create your administrator account.</p>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Access Your Instance</div>
                            <div class="step-content">
                                <p>Open <code>http://localhost:3000</code> in your browser and log in with your admin
                                    credentials.</p>
                            </div>
                        </div>
                    </div>

                    <div class="card">
                        <h3 class="card-title">πŸ“ Docker Compose Configuration</h3>
                        <pre><code>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:</code></pre>
                    </div>
                </section>

                <!-- Vercel -->
                <section id="vercel">
                    <h2>β–² Vercel Deployment</h2>
                    <p>Deploy OpenCodeHub as a serverless application with automatic scaling.</p>

                    <div class="alert alert-warning">
                        <div class="alert-title">⚠️ Important Note</div>
                        <p>Git repository storage requires external storage (S3, R2, etc.) when using Vercel.</p>
                    </div>

                    <div class="steps">
                        <div class="step">
                            <div class="step-title">Fork the Repository</div>
                            <div class="step-content">
                                <p>Fork <a href="https://github.com/swadhinbiswas/OpencodeHub">OpenCodeHub on GitHub</a>
                                    to your account.</p>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Import to Vercel</div>
                            <div class="step-content">
                                <p>Go to <a href="https://vercel.com/new">vercel.com/new</a> and import your forked
                                    repository.</p>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Configure Environment Variables</div>
                            <div class="step-content">
                                <p>Add the following environment variables in Vercel project settings:</p>
                                <table>
                                    <thead>
                                        <tr>
                                            <th>Variable</th>
                                            <th>Description</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td><code>DATABASE_URL</code></td>
                                            <td>PostgreSQL connection string (use Vercel Postgres or external)</td>
                                        </tr>
                                        <tr>
                                            <td><code>JWT_SECRET</code></td>
                                            <td>32+ character secret for JWT tokens</td>
                                        </tr>
                                        <tr>
                                            <td><code>SESSION_SECRET</code></td>
                                            <td>32+ character secret for sessions</td>
                                        </tr>
                                        <tr>
                                            <td><code>SITE_URL</code></td>
                                            <td>Your Vercel deployment URL</td>
                                        </tr>
                                        <tr>
                                            <td><code>STORAGE_TYPE</code></td>
                                            <td>Set to <code>s3</code> for cloud storage</td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Deploy</div>
                            <div class="step-content">
                                <p>Click "Deploy" and wait for the build to complete. Your instance will be available at
                                    your Vercel URL.</p>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- VPS -->
                <section id="vps">
                    <h2>πŸ–₯️ VPS / Linux Deployment</h2>
                    <p>Full control deployment on any Linux server with systemd and Nginx.</p>

                    <div class="alert alert-info">
                        <div class="alert-title">πŸ’‘ Recommended Specs</div>
                        <p>2+ CPU cores, 4GB+ RAM, 50GB+ SSD. Ubuntu 22.04 or Debian 12 recommended.</p>
                    </div>

                    <div class="steps">
                        <div class="step">
                            <div class="step-title">Install Dependencies</div>
                            <div class="step-content">
                                <pre><code># 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</code></pre>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Setup PostgreSQL</div>
                            <div class="step-content">
                                <pre><code># 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</code></pre>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Clone and Configure</div>
                            <div class="step-content">
                                <pre><code># 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</code></pre>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Create Systemd Service</div>
                            <div class="step-content">
                                <pre><code># Create service file
sudo nano /etc/systemd/system/opencodehub.service</code></pre>
                                <pre><code>[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</code></pre>
                                <pre><code># Enable and start service
sudo systemctl enable opencodehub
sudo systemctl start opencodehub</code></pre>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Configure Nginx</div>
                            <div class="step-content">
                                <pre><code># Create Nginx config
sudo nano /etc/nginx/sites-available/opencodehub</code></pre>
                                <pre><code>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;
    }
}</code></pre>
                                <pre><code># Enable site
sudo ln -s /etc/nginx/sites-available/opencodehub /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx</code></pre>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- SSL -->
                <section id="ssl">
                    <h2>πŸ” SSL Certificate Setup</h2>
                    <p>Secure your OpenCodeHub instance with HTTPS using Let's Encrypt.</p>

                    <div class="steps">
                        <div class="step">
                            <div class="step-title">Install Certbot</div>
                            <div class="step-content">
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">sudo apt install certbot python3-certbot-nginx</span>
                                </div>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Obtain Certificate</div>
                            <div class="step-content">
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">sudo certbot --nginx -d git.yourdomain.com</span>
                                </div>
                                <p>Follow the prompts. Certbot will automatically configure Nginx for HTTPS.</p>
                            </div>
                        </div>

                        <div class="step">
                            <div class="step-title">Auto-Renewal</div>
                            <div class="step-content">
                                <p>Certbot automatically sets up certificate renewal. Test it with:</p>
                                <div class="command-line">
                                    <span class="command-prompt">$</span>
                                    <span class="command-text">sudo certbot renew --dry-run</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Production Checklist -->
                <section>
                    <h2>βœ… Production Checklist</h2>

                    <div class="card">
                        <h3 class="card-title">Before Going Live</h3>
                        <ul>
                            <li>βœ… Set strong secrets (JWT_SECRET, SESSION_SECRET, INTERNAL_HOOK_SECRET)</li>
                            <li>βœ… Configure HTTPS with valid SSL certificate</li>
                            <li>βœ… Set correct SITE_URL in environment</li>
                            <li>βœ… Enable rate limiting (RATE_LIMIT_SKIP_DEV=false)</li>
                            <li>βœ… Enable CSRF protection (CSRF_SKIP_DEV=false)</li>
                            <li>βœ… Configure database backups</li>
                            <li>βœ… Set up monitoring and alerts</li>
                            <li>βœ… Create admin account with 2FA</li>
                        </ul>
                    </div>
                </section>

                <!-- Footer -->
                <footer
                    style="margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--border-primary); text-align: center; color: var(--text-muted);">
                    <p>
                        Made with ❀️ by <a href="https://github.com/swadhinbiswas">Swadhin Biswas</a> β€’
                        <a href="https://github.com/swadhinbiswas/OpencodeHub">GitHub</a>
                    </p>
                </footer>
            </div>
        </main>
    </div>

    <script>
        // Smooth scroll for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>

</html>