Skip to content

fix(deploy): make the vm stack start, deploy and restore - #43

Merged
Vishwas1345 merged 3 commits into
mainfrom
fix/vm-deploy-scripts
Oct 16, 2026
Merged

Vishwas1345 merged 3 commits into
mainfrom
fix/vm-deploy-scripts

Conversation

@Vishwas1345

Copy link
Copy Markdown
Owner

Why

The audit found the VM deploy path (docker-compose.prod.yml, Caddy, scripts/deploy|backup|restore.sh) had never been run. I ran it end to end locally with SITE_DOMAIN=localhost, and it could not start. The live Render deploy does not use any of this.

Bugs fixed (each found by running it)

Bug Effect Fix
Scripts committed without the exec bit ./scripts/deploy.sh -> permission denied on any clone chmod +x in git
First deploy backs up a database that is not running First deploy aborts Back up only if postgres is running
trusted_proxies as a global Caddy option Caddy refuses its config, proxy crash-loops (also on main) Moved under servers { }
Empty CREDENTIALS_KEY from compose API refuses to start with the documented minimal config Empty counts as unset (+ tests)
restore.sh used pg_restore on backup.sh's plain SQL, and counted tables in postgres A restore could never succeed psql replay; every query names its database
Caddy sent /api/events/stream to api:4000 Browser reached the API directly Stream goes through the web relay (flush_interval -1 kept)
Redis allkeys-lru Queued jobs could be evicted noeviction
deploy.sh health check went via the proxy Proxy failure reported as "API never became healthy" Two checks, each naming its part

Also: the unread API_PUBLIC_URL removed; SEED_OPERATOR_USERNAME/PASSWORD added to .env.production.example.

Verified locally

  • deploy.sh first run on an empty host (backup skipped), second run with a backup; both health checks pass
  • HTTPS through Caddy (internal cert for localhost), http -> 308 https, all five security headers
  • operator sign-in; live stream through Caddy and the web relay opens with event: ready; signed out it redirects to login
  • restore.sh on a real dump: 15 tables, scratch DB dropped, live DB untouched; a dump with no tables exits 1
  • lint, typecheck, unit (693 api, 141 web), integration 238 twice on a fresh DB
  • test stack, volumes, images, dumps and the local .env.production removed afterwards

Not verified: a real host, a Let's Encrypt certificate, public traffic.

🤖 Generated with Claude Code

Vishwas1345 and others added 3 commits October 16, 2026 11:56
The production compose passes ${CREDENTIALS_KEY:-}, so leaving the optional
key out produced an empty string the base64 check rejected, and the API never
started.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Found by running it end to end for the first time:
- deploy.sh, backup.sh and restore.sh were committed without the exec bit
- the first deploy backed up a database that was not running yet, and aborted
- Caddy refused its config: trusted_proxies belongs under servers
- restore.sh fed backup.sh's plain-SQL dump to pg_restore, and counted tables
  in the wrong database
- the live stream bypassed the web relay to reach the API directly
- Redis could evict queued jobs (allkeys-lru, now noeviction)
Also drops the unread API_PUBLIC_URL, adds the seed operator to the example
env, and splits deploy.sh's health check so a failure names its part.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Vishwas1345
Vishwas1345 merged commit 2abb089 into main Oct 16, 2026
8 checks passed
Vishwas1345 added a commit that referenced this pull request Oct 16, 2026
The skills' check was npm run build, which never typechecks the tests; the
recovery-action recipe missed the database enum, migration and policy table.
Records #34-#43, the owner's push rule (trivial changes to main, everything
else through a PR) and the narrowed vendor rule (no lab-platform or company
names; tool and host names are fine).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vishwas1345 added a commit that referenced this pull request Oct 16, 2026
ARCHITECTURE gains Google sign-in, both deploy shapes, the demo reset, the
security headers and an audit-action table, and drops an invented production
shape. INFRA, DEPLOYMENT and GAPS make Render the live path and state the
rate limits as shared. PLAN records #34-#43; acceptance criteria are ticked
where a test proves them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vishwas1345 added a commit that referenced this pull request Oct 16, 2026
DEPLOYMENT.md is rewritten for Render alone (440 lines to 140); every other
doc drops the VM path, keeping #38 and #43 as history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vishwas1345 added a commit that referenced this pull request Oct 16, 2026
DEPLOYMENT.md is rewritten for Render alone (440 lines to 140); every other
doc drops the VM path, keeping #38 and #43 as history.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant