Commit Graph

17 Commits

Author SHA1 Message Date
JasonFraser c8be366015 Fix marketing container staleness for real: recreate on every deploy, not just HTML edits
Found live: box.bettersight.io's hero image 404'd again after a deploy
that touched zero marketing-related files (a dev.sh/prod.sh/tests-only
commit). Root cause was deeper than the original content-hash fix
assumed — Dokploy re-clones the ENTIRE git checkout on every deploy, not
just ones that change bettersightbox-index.html, which orphans
marketing's assets/ directory bind mount (the container's mount still
points at the old, now-deleted directory inode) whenever the container
itself isn't also recreated in that same deploy. A hash of one file's
content only caught deploys that touched that file.

Fix: generate-dokploy-compose.sh now bakes in the current git commit SHA
instead, so the content-hash label (and the recreate it forces) changes
on every single deploy, unconditionally.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-04 17:56:39 -04:00
JasonFraser f6983d13d7 Fix INSTALLATION_PLAYBOOK.md: backend-billing pull_policy must be always, not missing
Found live: BACKEND_BILLING_PULL_POLICY=missing only re-pulls an image if
the tag isn't already cached on the VPS, so a scripts/prod.sh push under
the same :latest tag was silently never picked up on redeploy — the
container kept running stale code with no error anywhere. Every other
image in this project already defaults to "always"; this one should too.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-04 16:17:29 -04:00
JasonFraser c35003c2fa Add Resend contact-form wiring, hero image, mobile-nav fix; add website/ (bi.bettersight.io + bettersight.io)
Sightbox marketing page (box.bettersight.io):
- Mobile nav now closes when a menu link is clicked
- Contact form posts to a new backend/billing/contact_lead.py route,
  proxied same-origin through the marketing nginx container to
  backend-billing, which notifies via Resend
- Hero section now uses assets/building.jpg as its background

Reorganize: bettersightbox-index.html + its nginx config + assets move to
website/website-bettersightbox/, colocated with two new sibling sites:
- website/ (root) — bi.bettersight.io (Bettersight Intelligence)
- website/website-bettersight.io/ — bettersight.io (parent company apex
  page), given the same mobile-nav/contact-form treatment as box's page,
  sharing website/backend's existing Resend-based /api/contact endpoint
- website/docker-compose.yml's backend service moved off env_file (never
  survives Dokploy's AutoDeploy re-clone) onto plain environment: vars,
  same fix already proven for backend-billing

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-04 16:06:56 -04:00
JasonFraser 219af05c74 Fix marketing container never recreating on AutoDeploy
Confirmed the hard way, live in production: Docker Compose only
recreates a container when its own service definition changes (image,
env, labels...), never from a bind-mounted file's content changing on
disk by itself. marketing's service definition never changes between
deploys, so Dokploy's AutoDeploy -- which wipes and re-clones the whole
git checkout, including bettersightbox-index.html, on every push -- had
never once recreated that container. It kept serving a September-dated,
weeks-stale copy of the page indefinitely, orphaned from the fresh file
sitting right next to it on disk, through every single deploy since
Stage 1.

generate-dokploy-compose.sh now computes a real sha256-based hash of
bettersightbox-index.html and bakes it into the marketing service as a
literal content-hash label -- the one value in the whole generated file
that's deliberately NOT left as a live ${VAR} reference, since its only
job is to actually change when the file's content changes, giving
Compose's own diffing a real reason to recreate the container. Local
dev (where this bug doesn't apply, no AutoDeploy wipe-and-reclone cycle)
keeps the ${MARKETING_HTML_HASH:-dev} default.

Documented in CLAUDE.md and CICD_PLAYBOOK.md: regenerate
docker-compose.dokploy.yml any time bettersightbox-index.html changes,
not just when docker-compose.yml itself changes -- skipping it silently
leaves the marketing page stale with no error anywhere.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-04 14:05:40 -04:00
JasonFraser 8ac5f12acd Make backup/.env durable under Dokploy via BACKUP_ENV_FILE override
Confirmed the hard way, live, on the migrated deployment: backup.sh
stopped every writer container, archived everything, restarted
containers -- all successfully -- and only failed on "rclone: command
not found" that run. Re-running after the rclone self-install fix then
hit a second, deeper problem: backup/.env itself had been wiped by the
Dokploy redeploy in between, since it lived next to backup.sh inside the
git checkout. This is the exact backup/restore-vs-AutoDeploy
architectural tension flagged earlier in this project but never
resolved until now -- same category of bug as backend/.env and
tenants.json before it.

BACKUP_ENV_FILE (new, defaults to the old next-to-the-script path for
local dev / a traditional non-Dokploy VPS, where the checkout is
stable) lets a Dokploy deployment's cron entry point backup.sh at
$SIGHTBOX_DATA_DIR/backup.env instead -- durable, survives every
redeploy, same pattern as TENANTS_JSON_PATH. Documented in both
INSTALLATION_PLAYBOOK.md Stage 10 and BACKUP_RESTORE.md, including the
corrected cron entry (the Dokploy-managed checkout path, not the
traditional /opt/sightbox/app assumption the original cron example
baked in).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 23:42:03 -04:00
JasonFraser 9faeeb7ee0 backup.sh: self-install rclone if missing, matching restore.sh
Confirmed the hard way on a fresh VPS: backup.sh stopped every writer
container, archived everything, then failed outright on "rclone:
command not found" during the upload step -- restore.sh already
self-installs rclone (same rclone.org/install.sh) for exactly this
scenario, backup.sh just never got the same treatment. Checked up front
now, before anything stateful (stopping containers) happens.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 23:39:14 -04:00
JasonFraser e863fcdb5b Document manual billing restore when a client isn't on real Stripe yet
reenable_users() is only ever called from the signed /webhook/stripe/
<slug> route -- there's no separate restore endpoint -- so a trial-timer
test or a client paying by some other means for now has no way to clear
a lockout without calling it directly. billing.py is deliberately built
for exactly this ("No Flask/HTTP objects imported here by design...
testable without a running Flask app"), so this is the documented entry
point with its HTTP wrapper removed, not a workaround.

Verified live against sample: restored every User the lockout snapshot
recorded (dispatcher, store manager, the Setup Wizard admin account, the
Stock Viewer demo account), zero failures.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 23:31:12 -04:00
JasonFraser 20c0fd0d45 Drop Technician system accounts; document Stock Viewer across the personas
Propagates this session's permissions-review decision through every doc
that described the old three-persona model: Technician's own Stock User
login is removed entirely (full create/submit/cancel rights with no
restriction tying a transaction to who it's "for" meant nothing stopped
a technician from issuing stock to themselves) in favor of phone-based
reporting through the Dispatcher, who now also raises Material Requests
on a technician's behalf (CLIENT_DEMO_GUIDE.md Stage 4, previously
scripted as the technician logging in and raising it themselves).

Also documents the new Stock Viewer role everywhere the old personas
were: CLAUDE.md's persona table, INSTALLATION_PLAYBOOK.md Stage 8 (now
optional, alongside Dispatcher/Store Manager), and CLIENT_DEMO_GUIDE.md
Stage 7, which no longer demos a Technician "look don't touch" login
(there's no such login anymore) and instead demos the real Stock Viewer
account against the Damage & Cost Report / Serial No Ledger / a
read-only Stock Entry form.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 23:03:00 -04:00
JasonFraser dc763613c7 Document two Stage 6 CSV import gotchas, confirmed live on the sample site
Both found running the actual import against a real site, not guessed:
1. Warehouse's Company column must match the Company record's stored
   name exactly, including punctuation -- "Sample Co" vs the actual
   "Sample Co." (trailing period) failed the whole import with a
   misleading "value missing for Company" error.
2. Item's Reorder Level "Request for" column needs the warehouse's
   stored name AFTER ERPNext appends the company abbreviation on
   creation (Main Store -> Main Store - SC), not the plain name typed
   into the warehouse CSV -- using the plain name fails with "value
   missing for Warehouse."

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 22:17:03 -04:00
JasonFraser 3224e5f2fa Add Stage 6 CSV templates for Frappe's native Data Import tool
Replaces fully-manual Desk UI click-through for Item Groups/Warehouses/
Items with three fillable CSV templates imported via Frappe's own Data
Import tool (New Data Import -> Insert New Records -> upload -> Start
Import) -- no code, no custom app, consistent with this project's
native-only philosophy.

Headers are not hand-typed or guessed: generated directly from this
exact ERPNext version's own Exporter class (the same code
download_template uses) via bench console against the running instance,
including the Item Reorder child table's "Field Label (Parent Table
Label)" column convention for Reorder Level/Qty -- confirmed by
inspecting Exporter.get_all_exportable_fields' source, since a
child-table key must be the parent's fieldname (reorder_levels), not the
child doctype name (Item Reorder), which silently produces zero columns
if gotten wrong.

Followed up from a user question about cloning a site as a template to
skip reprovisioning -- assessed as unclean (Setup Wizard's company data
can't be cleanly redone on a clone, template would need to stay
permanently free of demo/real data) and recommended templating Stage 6
instead, since it's just data entry, not Frappe system state.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 22:00:28 -04:00
JasonFraser cde7dbd4c6 Make tenants.json durable: move its bind-mount source into SIGHTBOX_DATA_DIR
Confirmed the hard way on a fresh second deployment: the default bind
source (./backend/tenants.json, relative to the repo checkout) gets wiped
on every Dokploy AutoDeploy same as backend/.env used to — except worse,
Docker silently creates an empty DIRECTORY at a missing bind-mount source
instead of failing, which crashes backend-billing with a confusing
IsADirectoryError instead of an obvious missing-file error.

TENANTS_JSON_PATH (new, defaults to the old relative path for local dev)
lets production point this at an absolute path inside $SIGHTBOX_DATA_DIR
instead — survives every redeploy, and is already covered by backup.sh's
nightly snapshot for free, resolving the tenants.json backup-fidelity gap
flagged earlier but never addressed.

Also fixes a second bug this surfaced: generate-dokploy-compose.sh's
--no-interpolate flag leaves a variable-based bind source as a literal
unresolved string, which `docker compose config` can't recognize as a
path and silently mis-normalizes to type: volume instead of type: bind —
Dokploy then rejects it as "refers to undefined volume". Declaring
type: bind explicitly in docker-compose.yml's long-form volume entry
removes the guesswork regardless of interpolation.

Stage 1 now seeds the file empty (valid, zero-tenant config) before the
first docker compose up. Stage 9, BACKUP_RESTORE.md, and both backup
scripts updated to match where the file actually lives now.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 20:51:29 -04:00
JasonFraser 3ab0e1e2a0 Document dokploy-traefik's missing dokploy-network attachment (Stage 2a)
Confirmed the hard way on a real second-domain setup: TLS issuance
succeeded, the domain's Traefik labels were correctly applied to
frontend, and curl still got a clean 504 the entire time — because
dokploy-traefik (auto-provisioned once per VPS by Dokploy itself, not by
this project) had come back attached only to the default bridge network,
not dokploy-network, so it had no path to the container it was routing
to. Every other symptom pointed at a labels/DNS problem; it wasn't.

Documents the check (docker inspect dokploy-traefik's NetworkSettings)
and fix (docker network connect dokploy-network dokploy-traefik), plus
the caveat that the fix isn't persistent — it would need reapplying if
Dokploy ever recreates its own Traefik container.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-03 18:28:28 -04:00
JasonFraser d33281a8e4 Document per-client domain routing: wildcard DNS + Dokploy Domain + site name
Adds the previously-undocumented step between bringing up the stack and
creating a site: how a real client actually gets a reachable domain.
Decision (discussed with the user): subdomains of box.bettersight.io,
dot-hierarchy (client1.box.bettersight.io, not client1-box.bettersight.io)
specifically so one wildcard DNS record covers every future client
forever, no DNS touched again per onboarding.

Folded into Stage 1 (one-time wildcard A record at Namecheap, skipped for
local dev and for every client after the first) and Stage 2, split into
2a (Dokploy Domain entry routing the subdomain to frontend:8080 with
Let's Encrypt) and 2b (bench new-site using that exact domain, since
FRAPPE_SITE_NAME_HEADER=$host means the site folder name must match the
Host header verbatim). Deliberately did not renumber Stage 2 onward —
too many other files cross-reference exact stage numbers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-02 07:54:16 -04:00
JasonFraser 76f43abad0 Retire backend/.env for durable Dokploy env vars; pre-build backend-billing image
Confirmed the hard way against a live Dokploy AutoDeploy: the code/
checkout is deleted and re-cloned on every deploy, so backend/.env (an
env_file: mount) never survived to the next deploy. Moved its four values
to plain environment: vars sourced from Dokploy's own Environment tab,
which persists across deploys independent of the git-clone wipe.

Also switches backend-billing to the same build-locally-push-to-registry-
pull pattern already used for erpnext-image, so the Dokploy VPS never
builds anything itself (backend/build.sh) — the user's explicit goal of
making this resilient to future frappe_docker/dependency changes, not
just today's deploy error.

Propagated through docker-compose.yml/.dokploy.yml, .env + .env.example,
CLAUDE.md, INSTALLATION_PLAYBOOK.md, CICD_PLAYBOOK.md, BACKUP_RESTORE.md,
backup.sh/restore.sh, and .gitignore's comments.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-02 06:07:57 -04:00
JasonFraser 0c1b8d7dc3 Add docker-compose.dokploy.yml — Dokploy rejects docker-compose.yml's include:
Confirmed on a real deploy: Dokploy's own compose validator fails with
"Additional property include is not allowed" before docker compose ever
runs, since it doesn't support the include: directive (open upstream
issues Dokploy/dokploy#3116 and #1727, neither implemented). Added
generate-dokploy-compose.sh to produce a flattened equivalent via
`docker compose config --no-interpolate --no-path-resolution` — both
flags load-bearing, not incidental (see the script's own header comment).
Submodule fetch for frappe_docker (via Dokploy's Enable Submodules toggle)
was confirmed working in the same deploy attempt.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-02 05:15:40 -04:00
JasonFraser 016de0a78d Document backend/.env as a Stage 1 requirement, not Stage 9 2026-10-02 05:07:01 -04:00
JasonFraser 677201bd8d Initial commit: Sightbox Phase 0 — native ERPNext deployment
Native ERPNext/Frappe configuration (provisioning script, playbooks,
demo guides), the backend/ billing service (the one piece of custom
code), erpnext-image branding, backup/restore tooling, and
frappe_docker as a pinned submodule.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pc2x7vyuUofdT3kLuqF3Y
2026-10-01 20:10:06 -04:00