diff --git a/playbook/INSTALLATION_PLAYBOOK.md b/playbook/INSTALLATION_PLAYBOOK.md index 4993af4..57d577a 100644 --- a/playbook/INSTALLATION_PLAYBOOK.md +++ b/playbook/INSTALLATION_PLAYBOOK.md @@ -31,8 +31,8 @@ VPS (one docker compose stack = one bench, one Stage 1) │ ├── acme site's database │ └── beta site's database ├── sites/ ← one shared volume, one folder per site -│ ├── acme.localhost/ -│ └── beta.localhost/ +│ ├── acme.box.bettersight.io/ (acme.localhost/ for local dev — see Stage 2) +│ └── beta.box.bettersight.io/ └── backup.sh → one nightly archive → R2 (every site above, together — see Stage 10) ``` @@ -59,8 +59,9 @@ per-client backup. - This repo's structure copied to wherever this VPS's stack will live (skip if it already exists — see "Architecture" above). -- Decided: the site name (a real domain in production, `.localhost` for local testing), - a DB password, and an Administrator password. +- Decided: the site name — in production, `.box.bettersight.io` (see Stage 1's + wildcard DNS note and Stage 2 below), `.localhost` for local testing — a DB password, + and an Administrator password. --- @@ -151,7 +152,56 @@ container, the same way it never touches MariaDB or Redis. If QR codes aren't ge site, confirm this container is actually running (`docker compose ps`) before suspecting the provisioning script. -## Stage 2 — Create the site +**Real client via Dokploy only — one-time per VPS, skip for local dev and skip entirely if +already done for this VPS.** Every client site on this box lives under one dedicated subdomain — +`box.bettersight.io` — as `.box.bettersight.io`. One wildcard DNS record covers every +client forever; new clients never need a new DNS entry, only Stage 2's per-client Dokploy Domain +below. + +In Namecheap: Domain List → **Manage** next to `bettersight.io` → **Advanced DNS** tab → **Add New +Record**: + +| Type | Host | Value | TTL | +|----------|--------|-------------------------------|-----------| +| A Record | `*.box` | `` | Automatic | + +Confirm it resolves before moving on — Namecheap propagation is usually fast but can take up to +~30 min: +``` +dig +short anything-at-all.box.bettersight.io +``` +should return the VPS's IP. + +⚠ This wildcard matches exactly one label under `box` (`client1.box.bettersight.io`) — it does +**not** cover `box.bettersight.io` itself (add a separate, non-wildcard record if that bare +domain should resolve to anything, e.g. a shared landing page) and does not cover a second-level +label (`a.b.box.bettersight.io`), which this design never needs since every client is exactly one +label deep. + +## Stage 2 — Route the domain and create the site + +**Adding another client?** Both steps below are per-client — run them even if Stage 1's wildcard +DNS is already in place. + +### 2a. Point this client's domain at Dokploy + +Dokploy dashboard → this Compose application → **Domains** tab → **Add Domain**: + +- **Host**: `.box.bettersight.io` +- **Service Name**: `frontend` +- **Container Port**: `8080` (`frontend`'s internal port — see `frappe_docker/overrides/compose.noproxy.yaml`; not `HTTP_PUBLISH_PORT`, which is only the *local-dev* host-port mapping) +- **HTTPS**: enabled, Certificate: **Let's Encrypt** + +Save, then redeploy. ⚠ **Per Dokploy's own docs (not yet confirmed live against a second real +client domain by us):** a Compose app's domain settings are applied as Traefik labels at deploy +time, not the moment you click Save — the new domain won't actually route anywhere until the next +deploy finishes. Dokploy generates these labels itself; nothing to hand-edit in +`docker-compose.yml`/`docker-compose.dokploy.yml` for this. + +Skip this sub-step entirely for local dev — `.localhost` needs no DNS or Dokploy domain, +just the site name below. + +### 2b. Create the Frappe site ``` docker compose exec backend bench new-site \ @@ -162,10 +212,19 @@ docker compose exec backend bench new-site \ --admin-password '' ``` +⚠ **The site name must be exactly the domain the browser will send as its Host header** — in +production, `.box.bettersight.io` from 2a above, verbatim; for local dev, +`.localhost`. `FRAPPE_SITE_NAME_HEADER` defaults to `$host`, so Frappe resolves which +site's folder to serve purely off that header — a mismatch (e.g. creating the site as +`client1.localhost` in production) means the domain routes through Dokploy fine but Frappe 404s +or serves the wrong site underneath it. + ## Stage 3 — Complete the real Setup Wizard — do not script around this -Log in as Administrator at `http:///login` and walk through the actual browser wizard: -company name, abbreviation, currency, country, domain. +Log in as Administrator at `/login` (`https://client1.box.bettersight.io/login` in +production, once Stage 2a's domain is live — `http://.localhost:8083/login` for local +dev) and walk through the actual browser wizard: company name, abbreviation, currency, country, +domain. **Bypassing this causes confirmed bugs**, all discovered the hard way: 1. No default language set → a Frappe locale crash (`UnboundLocalError`). This isn't limited to