Story 54: add cross-platform binary distribution support

- Add Makefile with build-macos and build-linux targets
  - build-macos: cargo build --release (native macOS binary)
  - build-linux: cross build --release --target x86_64-unknown-linux-musl
    (produces a fully static binary via Docker/cross; zero dynamic deps)
- Document cross-platform build process in README.md including
  how to verify macOS dynamic deps (otool -L) and Linux static
  linking (file + ldd)
- reqwest 0.13 already uses rustls by default (no OpenSSL); verified
  in Cargo.lock – no Cargo.toml changes needed
- Add unit tests to http/assets.rs covering:
  - SPA fallback routing for non-asset paths
  - 404 for missing assets/ paths
  - Panic-free behaviour on empty path
  - rust-embed EmbeddedAssets iter compiles and runs correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dave
2026-02-20 17:13:59 +00:00
parent d496b9a839
commit 158550e889
3 changed files with 123 additions and 0 deletions

View File

@@ -27,6 +27,55 @@ cargo build --release
./target/release/story-kit-server
```
## Cross-Platform Distribution
Story Kit ships as a **single self-contained binary** with the React frontend embedded via
`rust-embed`. No Rust toolchain, Node.js, or extra libraries are required on the target machine.
### macOS
```bash
# Native build no extra tools required beyond Rust + pnpm
make build-macos
# Output: target/release/story-kit-server
# Verify only system frameworks are linked (Security.framework, libSystem.B.dylib, etc.)
otool -L target/release/story-kit-server
```
### Linux (static x86_64, zero dynamic deps)
The Linux build uses the `x86_64-unknown-linux-musl` target to produce a fully static binary.
**Prerequisites:**
```bash
# Install cross a Rust cross-compilation tool backed by Docker
cargo install cross
# Ensure Docker Desktop (or Docker Engine) is running
```
**Build:**
```bash
make build-linux
# Output: target/x86_64-unknown-linux-musl/release/story-kit-server
# Verify the binary is statically linked
file target/x86_64-unknown-linux-musl/release/story-kit-server
# Expected: ELF 64-bit LSB executable, x86-64, statically linked
ldd target/x86_64-unknown-linux-musl/release/story-kit-server
# Expected: not a dynamic executable
```
**Running on any Linux x86_64 machine:**
```bash
# No Rust, Node, glibc, or any other library needed just copy and run
./story-kit-server
```
## Testing