Skip to content

T-4: Add Lightsail deploy script, nginx snippet and Deploy docs - #32

Merged
Ghigog merged 1 commit into
mainfrom
formic/t-4-584562
Dec 1, 2026
Merged

Ghigog merged 1 commit into
mainfrom
formic/t-4-584562

Conversation

@Ghigog

@Ghigog Ghigog commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Added deploy/deploy.sh (env-var checks before building, --dry-run, --skip-build, rsync --delay-updates over SSH), deploy/nginx/dojo.conf (wasm/mjs MIME, immutable caching for assets/, no-cache index.html, gzip, 404 with no SPA fallback), a README Deploy section and updated Status, and AGENTS.md entries.
Verified: bash -n and shellcheck clean; missing var exits 1 naming it before building; --dry-run builds and prints the rsync command (the transfer itself could not connect to a placeholder host); nginx syntax ok (full -t only failed on log-file permissions in this sandbox).
The served URL is a placeholder in README until the host name is known.

Plan:

  • Read repo
  • deploy.sh
  • dojo.conf
  • README and AGENTS
  • Verify

Formic-Usage: {"model":"sonnet","tokensIn":140442,"tokensOut":4542,"costCents":0}

Closes #23.

T-4 — Deploy the static dist/ build to the existing Lightsail nginx

User story: As a DJ practising with DoJo, I'd like to open the Phase 1 trainer at a URL served from our Lightsail instance, so that I can train in any browser without cloning the repo and running a dev server.

Requirements

  • Depends on EPIC-4-T9 (the assembled trainer) so there is a real app in dist/ to deploy.
  • Add a top-level deploy/ directory with deploy/deploy.sh (bash, set -euo pipefail) that runs npm ci && npm run build (or skips the build with a flag) and rsyncs dist/ over SSH to the box. Host, SSH user and remote web root come from env vars (e.g. DOJO_DEPLOY_HOST, DOJO_DEPLOY_USER, DOJO_DEPLOY_PATH) with no hostnames, keys or secrets committed; the script fails with a clear message when one is missing and supports a --dry-run that prints the rsync it would run (rsync --dry-run). Upload hashed assets before index.html (or use --delay-updates) so a visitor never gets an index.html pointing at assets not yet uploaded.
  • Add deploy/nginx/dojo.conf: a server/location snippet serving the web root as static files. Explicitly map .wasm to application/wasm and .mjs to text/javascript (older nginx mime.types lack them) alongside the default mime.types; assets/ (Vite's content-hashed output) gets Cache-Control: public, max-age=31536000, immutable; index.html gets Cache-Control: no-cache; gzip on for js/css/svg/wasm. The app has no client-side routing (single index.html, vite base './'), so use try_files $uri $uri/ =404 and NO index.html fallback; say so in a comment. Keep server_name and root as clearly marked placeholders to adapt on the box.
  • Note: soundtouchjs 0.3 is plain JavaScript and Vite emits no .wasm today; the wasm mapping is there for a future time-stretch swap, so do not add any wasm code.
  • Document in README.md (replace the outdated 'no application code yet' Status line with real build/run/deploy info) a 'Deploy' section: prerequisites (SSH access, rsync, nginx on the box), the env vars, the one-command deploy, the one-time steps to install deploy/nginx/dojo.conf (copy to sites-available, symlink, sudo nginx -t && sudo systemctl reload nginx), how to roll back (redeploy a previous commit), and the URL/path the app is served at (placeholder to fill in if not known). Add deploy/ with its representative file to AGENTS.md's 'Where things are' and the deploy command to its Conventions.
  • Do not touch .github/workflows/, add no CI deploy, no other host (Vercel/Netlify/Pages), no backend, accounts or secrets. Verify with bash -n deploy/deploy.sh, shellcheck if available, deploy/deploy.sh --dry-run against a placeholder host, and nginx -t on the snippet if nginx is available locally (e.g. in Docker).

Acceptance criteria

  • Given a clean checkout with DOJO_DEPLOY_HOST, DOJO_DEPLOY_USER and DOJO_DEPLOY_PATH set, when the maintainer runs deploy/deploy.sh --dry-run, then it builds dist/ and prints the rsync transfer of dist/ to user@host:path without changing anything remotely.
  • Given one of the deploy env vars is unset, when deploy/deploy.sh is run, then it exits non-zero before building or uploading, naming the missing variable.
  • Given deploy/nginx/dojo.conf installed on the Lightsail nginx and dist/ deployed, when a browser at phone width opens the documented URL and requests index.html, a hashed file under assets/ and a .wasm path, then the trainer loads and looks exactly as it does under npm run preview (glass panels, Nunito font, no failed requests), index.html is served with Cache-Control: no-cache, assets/ files with max-age=31536000 immutable, and .wasm as application/wasm.
  • Given a request for a path that does not exist, such as /nope, when nginx serves it, then it returns 404 rather than index.html, since the app has no client-side routing.

File scope

AGENTS.md, README.md, deploy

No verification command was run.


Opened by a Formic Coder Agent.

Added deploy/deploy.sh (env-var checks before building, --dry-run, --skip-build, rsync --delay-updates over SSH), deploy/nginx/dojo.conf (wasm/mjs MIME, immutable caching for assets/, no-cache index.html, gzip, 404 with no SPA fallback), a README Deploy section and updated Status, and AGENTS.md entries.
Verified: bash -n and shellcheck clean; missing var exits 1 naming it before building; --dry-run builds and prints the rsync command (the transfer itself could not connect to a placeholder host); nginx syntax ok (full -t only failed on log-file permissions in this sandbox).
The served URL is a placeholder in README until the host name is known.

Plan:
- [x] Read repo
- [x] deploy.sh
- [x] dojo.conf
- [x] README and AGENTS
- [x] Verify

Formic-Usage: {"model":"sonnet","tokensIn":140442,"tokensOut":4542,"costCents":0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant