|
| 1 | +# Containerized development |
| 2 | + |
| 3 | +RSScript builds and runs identically on macOS, Windows, and Linux through a |
| 4 | +single Docker toolchain image. The container carries the Rust toolchain, the |
| 5 | +test runner, and the system libraries the workspace needs; your checkout is |
| 6 | +bind-mounted in, so edits on the host take effect immediately. |
| 7 | + |
| 8 | +This is the recommended setup for contributors who do not want to install the |
| 9 | +Rust toolchain and C build dependencies locally, and for keeping builds |
| 10 | +reproducible across platforms. |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- [Docker](https://docs.docker.com/get-docker/) with Compose v2 (`docker |
| 15 | + compose`). Docker Desktop (macOS/Windows) or Docker Engine (Linux) both work. |
| 16 | +- That's all — no local Rust, C compiler, or SQLite needed. |
| 17 | + |
| 18 | +## Quick start |
| 19 | + |
| 20 | +```sh |
| 21 | +# Build the dev image (first run downloads the toolchain; later runs are cached). |
| 22 | +docker compose build |
| 23 | + |
| 24 | +# Run the full test suite exactly as CI does. |
| 25 | +docker compose run --rm dev cargo run --bin rss -- test --all |
| 26 | + |
| 27 | +# Open an interactive shell in the toolchain. |
| 28 | +docker compose run --rm dev bash |
| 29 | +``` |
| 30 | + |
| 31 | +Inside the shell (or via `docker compose run --rm dev <cmd>`) every normal |
| 32 | +workflow is available: |
| 33 | + |
| 34 | +```sh |
| 35 | +cargo run --bin rss -- test --all # project test runner (nextest-backed) |
| 36 | +cargo nextest run -p rsscript # run one crate's tests |
| 37 | +cargo nextest run -p rsscript --features native-jit # Cranelift JIT tier |
| 38 | +cargo clippy --all-targets # lints |
| 39 | +cargo fmt --all # format |
| 40 | +cargo run --bin rss -- <args> # drive the rss CLI |
| 41 | +``` |
| 42 | + |
| 43 | +## How it is wired |
| 44 | + |
| 45 | +- **Image** (`Dockerfile`): `rust:1-bookworm` plus `build-essential`, `cmake`, |
| 46 | + and `pkg-config` (for `ring`/rustls and the bundled-SQLite `rusqlite`), |
| 47 | + `clippy`/`rustfmt`, and `cargo-nextest`. The workspace uses rustls/ring |
| 48 | + throughout, so no OpenSSL is required. |
| 49 | +- **Source** is bind-mounted at `/work` (see `compose.yaml`) — not copied into |
| 50 | + the image — so host edits are picked up with no rebuild. |
| 51 | +- **Caches** live in named volumes, deliberately kept off the host bind mount so |
| 52 | + compilation persists between runs and stays fast on macOS/Windows: |
| 53 | + - `target` → `/work/target` |
| 54 | + - `cargo-registry` → `/usr/local/cargo/registry` |
| 55 | + - `cargo-git` → `/usr/local/cargo/git` |
| 56 | + |
| 57 | + Reset a cache with `docker compose down -v` (removes all three volumes). |
| 58 | + |
| 59 | +## Reproducible toolchain |
| 60 | + |
| 61 | +The image tracks the latest stable Rust 1.x (`rust:1-bookworm`), which always |
| 62 | +satisfies the workspace's edition-2024 requirement (Rust ≥ 1.85). For a fully |
| 63 | +pinned toolchain, change the base tag in `Dockerfile` to a concrete version such |
| 64 | +as `rust:1.88-bookworm` and rebuild. |
| 65 | + |
| 66 | +## VS Code / Codespaces |
| 67 | + |
| 68 | +`.devcontainer/devcontainer.json` reuses the same compose service. In VS Code, |
| 69 | +run **Dev Containers: Reopen in Container**; on GitHub, **Create codespace**. |
| 70 | +You get rust-analyzer (clippy-backed), TOML, and LLDB wired to the identical |
| 71 | +toolchain and caches. |
| 72 | + |
| 73 | +## Apple Silicon and other architectures |
| 74 | + |
| 75 | +The image builds natively on both `amd64` and `arm64` (Apple Silicon); the |
| 76 | +nextest install picks the matching prebuilt binary and falls back to a source |
| 77 | +build elsewhere. No extra configuration is needed. |
0 commit comments