Embed webapp into the binary with fs-embed, drop --static-dir

ottyl was requiring webapp/dist to be shipped alongside the binary and
served via ServeDir/ServeFile pointed at a --static-dir CLI arg. Embed
the built webapp at compile time instead, so ottyl is a single
self-contained executable with no runtime static directory dependency.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
Hugh Kaznowski
2026-09-05 16:21:02 +01:00
co-authored by Claude Sonnet 5
parent 1d1b0eee01
commit 7694dcf120
6 changed files with 57 additions and 65 deletions
-37
View File
@@ -1,37 +0,0 @@
# 028 — Bundle the webapp with fs-embed, drop `--static-dir`
## Summary
`fs-embed` is already a `Cargo.toml` dependency but unused (`grep -rn
"fs_embed" src/` turns up nothing) — `src/api.rs` still serves the webapp via
`ServeDir`/`ServeFile` pointed at a `--static-dir` CLI arg
(`src/main.rs:35`), which requires shipping `webapp/dist` alongside the
binary. Embed the built webapp into the binary instead so `ottyl` is a single
self-contained executable.
## Scope
- Use `fs-embed` to embed `webapp/dist` at build time.
- Wire the embedded filesystem into `src/api.rs` in place of the
`ServeDir::new(static_dir).fallback(ServeFile::new(index_html))` setup
(`src/api.rs:100-101`), preserving the SPA fallback-to-`index.html`
behavior.
- Remove the `--static-dir` clap arg (`src/main.rs:30-35`) and its plumbing
through `api::router` (`src/api.rs:91`, `src/main.rs:108`).
- Update the test helper that builds a router against a temp static dir
(`src/api.rs:729-744`) to match the new embedding approach.
- `webapp/dist` must exist at `cargo build` time (i.e. the webapp build step
stays a prerequisite) — document that in the README's build instructions if
not already covered.
## Acceptance criteria
- `cargo build` (with `webapp/dist` present) produces a binary that serves
the webapp with no `--static-dir` flag and no `webapp/dist` directory
needed at runtime.
- `--static-dir` no longer appears in `--help` output or `Args`.
- Existing API tests pass against the embedded-filesystem router.
## Depends on
None.