fly deploy -c fly.saas.tomlNEVER use bare fly deploy. This project depends on LastSaaS for authentication. See lastsaas/CLAUDE.md "Dependent Project Deployment" for the full explanation.
The production deployment runs three processes behind Caddy (managed by supervisord):
- Caddy (port 8080) — reverse proxy, the only externally exposed port
- LLM Optimizer backend (port 8090) — analysis, optimization, all
/api/*product routes - LastSaaS backend (port 8091) — auth, OAuth, billing, admin, bootstrap
Caddy routes requests based on path:
/api/auth/*,/api/users/*,/api/tenants/*,/api/billing/*,/api/admin/*,/api/bootstrap/*,/health, etc. → LastSaaS (:8091)- Everything else → LLM Optimizer (:8090)
If you deploy with bare fly deploy (uses Dockerfile + fly.toml), only the llmopt backend runs. Auth endpoints return HTML from the SPA catch-all, OAuth providers disappear, and users get silently redirected to /setup.
-
If lastsaas submodule changed: push lastsaas to GitHub first, then pull into the submodule:
cd /Users/jonradoff/lastsaas && git push origin master cd /Users/jonradoff/llmopt/lastsaas && git pull origin master
The Docker build reads from the submodule directory, which tracks GitHub — not the local lastsaas working copy.
-
Build check:
cd /Users/jonradoff/llmopt/backend && go build ./... cd /Users/jonradoff/llmopt/frontend && npx tsc --noEmit
-
Deploy:
cd /Users/jonradoff/llmopt && fly deploy -c fly.saas.toml
- Visit https://llmopt.fly.dev/ — standalone frontend loads
- Visit https://llmopt.fly.dev/login — SaaS login page loads with OAuth buttons (Google)
- Check
fly logs -a llmopt— should see startup lines from both llmopt and lastsaas backends
| Symptom | Cause | Fix |
|---|---|---|
Redirects to /setup |
Deployed with wrong Dockerfile (no LastSaaS backend) | Redeploy with fly deploy -c fly.saas.toml |
| Login page missing OAuth buttons | LastSaaS backend not running | Same as above |
| Credentials not working | LastSaaS backend not running (auth API returns HTML) | Same as above |
| "App not listening on expected address" warning | Normal — WARP startup delay, Caddy binds after a few seconds | Wait; health checks pass shortly after |
fly.saas.toml → Dockerfile.saas
├── Stage 1: Build llmopt Go binary
├── Stage 2: Build LastSaaS Go binary
├── Stage 3: Build llmopt standalone frontend
├── Stage 4: Build SaaS frontend (LastSaaS + overlay)
└── Stage 5: Production runtime (Debian)
├── supervisord (PID 1)
│ ├── caddy (:8080)
│ ├── llmopt via start-saas.sh (:8090 + WARP)
│ └── lastsaas-server (:8091)
├── deploy/Caddyfile (routing rules)
└── deploy/supervisord.conf (process config)
Fly app: llmopt | Region: ewr | URL: https://llmopt.fly.dev/