This runbook is for a single self-hosted Deft workspace on a VPS. It assumes a
domain such as demo.example.com, one Linux server, Docker Compose, and a
reverse proxy that terminates HTTPS.
https://demo.example.com -> Deft web container :3000
https://demo.example.com/api/... -> Deft API container :3001
https://demo.example.com/oauth/... and /.well-known/... -> Deft API container :3001
Use one public origin for the web app and API. This is the smoothest shape for browser login, OAuth MCP discovery, ChatGPT/Claude/Codex connector setup, and cookie/CORS behavior.
Create an A record:
demo.example.com -> <your-vps-ip>
Wait until:
dig +short demo.example.comreturns the VPS IP.
Install Docker and the Compose plugin. Then clone Deft:
git clone https://github.com/Maneek21/Deft.git
cd Deft
cp .env.example .envGenerate required secrets:
openssl rand -hex 32 # POSTGRES_PASSWORD
openssl rand -hex 32 # JWT_SECRET
openssl rand -hex 32 # JWT_REFRESH_SECRET
openssl rand -hex 32 # ENCRYPTION_KEY, at least 32 charactersSet the public URLs in .env:
NEXT_PUBLIC_APP_URL=https://demo.example.com
NEXT_PUBLIC_API_URL=https://demo.example.com
NEXT_PUBLIC_WS_URL=https://demo.example.com
API_PORT=3001
DEFT_WEB_PORT=3000
DEFT_API_PORT=3001
DEFT_BIND_HOST=127.0.0.1The DEFT_BIND_HOST=127.0.0.1 default keeps Deft's app ports local to the VPS.
Only the reverse proxy should be public.
For a Docker-hosted demo where Caddy joins the Compose network, start from the
secret-free templates in deploy/demo/. Copy them to the repository root as
Caddyfile and compose.demo.yml, set DEFT_PUBLIC_HOST in .env, and include
the overlay in every Compose command. The root copies are intentionally
server-local; the examples are the versioned recovery source.
Example Caddyfile:
demo.example.com {
encode zstd gzip
handle /api/* {
reverse_proxy 127.0.0.1:3001
}
handle /oauth/* {
reverse_proxy 127.0.0.1:3001
}
handle /.well-known/* {
reverse_proxy 127.0.0.1:3001
}
handle {
reverse_proxy 127.0.0.1:3000
}
}If you use Nginx, keep the same routing split: /api, /oauth, and
/.well-known go to the API port; everything else goes to the web port.
For host-installed Caddy or Nginx, set DEFT_INVITE_TRUSTED_PROXIES in .env
to the proxy's actual socket peer address as seen by the API, then recreate
the deft container. This governs every IP rate limit: general API, invite
and the Apps limiters (App Runtime channel, public App routes, resource sync
and the App connection, data and job routes).
Without it, visitors share the proxy's budgets, including after an upgrade:
auth routes (including refresh) share 10 requests/minute in production,
login and MCP each share 120/minute, invites share 10/minute, and the App
Runtime channel shares 90/minute by default.
Authenticated user and channel-credential buckets are unchanged.
Direct API access needs no setting. Startup logs warn when the setting is absent.
With a native API on the same host the peer may be 127.0.0.1 or ::1. A host
proxy reaching a published Docker port often appears as the Docker bridge
gateway instead. Inspect the running container's network gateways, then confirm
which one is the proxy peer before trusting that exact address:
docker inspect --format '{{range .NetworkSettings.Networks}}{{println .Gateway}}{{end}}' \
"$(docker compose -f docker-compose.yml -f compose.prod.yml ps -q deft)"Use comma-separated exact IPs or DNS names you control, never a whole private
subnet. The trusted proxy must overwrite incoming X-Forwarded-For or append
the real immediate client as its final entry. For Nginx this is normally
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;; Caddy's default
forwarding behavior already meets this rule. X-Real-IP alone is not used.
The bundled Docker Caddy overlay supplies the trusted caddy service name
automatically; it does not apply to the host-installed proxy shown above.
From the repo:
pnpm selfhost:bootstrap --prod --check-only
pnpm selfhost:bootstrap --prodIf you do not have host-side Node.js/pnpm, run the Docker-only sequence:
docker compose -f docker-compose.yml -f compose.prod.yml build deft init doctor smoke
docker compose -f docker-compose.yml -f compose.prod.yml up -d
docker compose -f docker-compose.yml -f compose.prod.yml run --rm init
docker compose -f docker-compose.yml -f compose.prod.yml run --rm doctor
docker compose -f docker-compose.yml -f compose.prod.yml run --rm smokeFor a demo/pilot instance with seeded data:
pnpm selfhost:bootstrap --prod --seed-pilotDo not use --seed-pilot for a real customer workspace.
If the VPS already has a Deft stack and you want a clean first-signup workspace, use the reset command instead of manually dropping schemas or deleting Docker volumes. It takes a Postgres backup first, preserves reverse-proxy state, and validates the rebuilt app before returning. The command rebuilds the Deft, init, doctor, and smoke images before it drops the schema, so validation uses the checked-out code instead of a stale image.
Clean internal workspace:
pnpm selfhost:reset --prod --platform-only --force --force-production-resetClean demo workspace:
pnpm selfhost:reset --prod --seed-pilot --force --force-production-resetIf this VPS has an additional local Compose overlay, include it explicitly:
pnpm selfhost:reset --prod --compose-file compose.demo.yml --platform-only --force --force-production-resetDry-run first when you are unsure which stack will be touched:
pnpm selfhost:reset --prod --compose-file compose.demo.yml --platform-only --dry-runExpected post-reset shape for --platform-only:
orgs=0
org_members=0
spaces=0
projects=0
tasks=0
messages=0
users may be 1 because the platform seed creates Defty, the internal system
user. skills and employee_templates should be non-zero because platform
bundles are seeded.
Open:
https://demo.example.com
Create the owner account. Then verify public OAuth/MCP metadata:
curl https://demo.example.com/.well-known/oauth-protected-resource
curl https://demo.example.com/.well-known/oauth-authorization-serverThe protected resource metadata should name:
https://demo.example.com/api/mcp/v1
In Deft, go to Settings -> MCP Access, create a personal token, add it to
.env as DEFT_MCP_BEARER_TOKEN, and run:
docker compose -f docker-compose.yml -f compose.prod.yml run --rm smokeThat confirms an authenticated MCP tools/list call works from the running
deployment.
| Symptom | Likely cause | Fix |
|---|---|---|
| Login shows "Failed to fetch" | NEXT_PUBLIC_API_URL was built with the wrong URL |
Fix .env, rebuild with docker compose up -d --build |
| OAuth connector says metadata missing | Proxy does not route /.well-known/* to API |
Add the /.well-known API route to the proxy |
| OAuth token exchange fails by resource mismatch | Client uses a different MCP URL than metadata | Use exactly https://domain/api/mcp/v1 |
doctor fails CORS |
App/API origins do not match expected public URL | Set all NEXT_PUBLIC_* URLs to the same HTTPS origin |
| Smoke fails DCR | API is unreachable through proxy or /oauth/register not routed |
Route /oauth/* to API |
Versioned upgrades are supported from v0.2.0-preview.1 forward. From a source
checkout, run:
git pull --ff-only
pnpm selfhost:upgrade --prodFor a named release image:
export DEFT_IMAGE=ghcr.io/maneek21/deft:<target-version>
pnpm selfhost:upgrade --prod --releaseThe command prepares the image before downtime, stops app writes, takes a
Postgres backup, applies the checksumed schema upgrade, recreates Deft, and runs
doctor plus smoke. Add --compose-file compose.demo.yml or another site overlay
when required. Use --dry-run to inspect the sequence first.