Skip to content

feat(infrastructure): self-hosted deployment with Docker + OrbStack + Cloudflare Tunnel#35

Merged
Delqhi merged 1 commit into
mainfrom
feat/self-hosted-deploy-orb
Jun 12, 2026
Merged

feat(infrastructure): self-hosted deployment with Docker + OrbStack + Cloudflare Tunnel#35
Delqhi merged 1 commit into
mainfrom
feat/self-hosted-deploy-orb

Conversation

@Delqhi

@Delqhi Delqhi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Closes #34. Full self-hosting story: Dockerfile (multi-stage, multi-arch), docker-compose.yml, Caddyfile, scripts, PLAN_DEPLOY.md, .env.example, docker GH workflow. Validated locally: pnpm build SUCCESS, docker build --target deps SUCCESS, docker compose config valid, pnpm tsc --noEmit exit 0.

… Cloudflare Tunnel (closes #34)

## What

A complete self-hosting story that works on macOS (OrbStack) and on any
Linux VPS. No Vercel account required for production.

### Files

#### NEW
- `Dockerfile` (4-stage multi-stage):
  1. `deps` — pnpm install --frozen-lockfile on node:22-alpine
  2. `sin-code` — downloads the official Go binary from the
     SIN-Code-Bundle release (with `/releases/latest` fallback).
     Multi-arch via docker buildx TARGETARCH.
  3. `builder` — Next.js standalone build with `output: 'standalone'`
  4. `runner` — node:22-slim + the standalone bundle + the sin-code
     binary on PATH. Runs as non-root. Healthcheck on /api/sin/status.
- `docker-compose.yml` — 3 services: `webui` (Next.js), `caddy`
  (reverse proxy + auto-HTTPS), and optional `sin-code` behind the
  `--profile tools` flag.
- `Caddyfile` — reverse proxy :80 → webui:3000, with
  flush_interval -1 for SSE chat streams, security headers,
  gzip+zstd encoding.
- `.dockerignore` — excludes node_modules, .next, .sin, .env*.local,
  IDE noise, *.db, etc.
- `.env.example` — every env var documented, with a comment about
  what it does. No values.
- `.github/workflows/docker.yml` — multi-arch (amd64+arm64) build +
  push to ghcr.io on every release tag (and on main for testing).
  Uses docker/build-push-action@v6 with GHA cache.
- `scripts/orb-up.sh` / `scripts/orb-down.sh` — one-command start
  and stop of the compose stack. Auto-detects the docker binary
  (OrbStack on macOS, Docker Engine on Linux), creates `.env` from
  `.env.example` if missing.
- `scripts/tunnel-up.sh` — starts a `cloudflared` quick tunnel for a
  public `*.trycloudflare.com` URL (no domain or account needed).
  Verifies the stack is running first.
- `PLAN_DEPLOY.md` (10 KB) — full architecture diagram, three
  topologies (macOS dev / Linux dev / VPS prod), build details,
  environment variables, troubleshooting matrix, rollback
  procedure, production checklist.

#### MODIFIED
- `next.config.mjs` — added `output: 'standalone'` for the small
  self-contained runtime image.

## Reality checks done locally

- `pnpm build` → SUCCESS, 10 routes (2 static + 8 dynamic)
- `docker build --target deps .` → SUCCESS, pnpm install in 47s
- `docker compose config` → valid, no cycle (after the first
  attempt created `caddy → webui → caddy`, removed webui's
  `depends_on: caddy`)
- `pnpm tsc --noEmit` → exit 0

## Production deployment (VPS)

1. SSH into any Ubuntu VPS
2. `curl -fsSL https://get.docker.com | sh`
3. `git clone https://github.com/OpenSIN-Code/SIN-Code-WebUI-v2`
4. `cp .env.example .env && nano .env` (set AI_GATEWAY_API_KEY)
5. `./scripts/orb-up.sh` — works on Linux via docker fallback
6. Optional: `cloudflared tunnel create sin-code-webui` + put
   `TUNNEL_TOKEN` in .env for a named Cloudflare tunnel

## Verification
- pnpm tsc --noEmit → exit 0
- secret scan on staged diff → 0 hits (no real vck_ keys)
- docker compose config → valid
- docker build --target deps → success
- Caddyfile + scripts + PLAN_DEPLOY.md reviewed for shell-syntax
  and consistency

## Closes
Closes #34
@github-actions

Copy link
Copy Markdown

CEO Audit — Not applicable

This repository is a Node.js / TypeScript project.
The CEO Audit is a Python tool; running it on a non-Python
repo would produce a misleading grade.

Recommended checks for this repo:

  • pnpm tsc --noEmit (type safety)
  • pnpm lint (style)
  • pnpm test (unit tests, when added)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[infrastructure] self-hosted deployment with Docker + OrbStack + Cloudflare Tunnel

1 participant