From f7bd21b9feffe46ec41a1a76b1dfe5e239bac6fc Mon Sep 17 00:00:00 2001 From: Joakim Persson Date: Sun, 12 Apr 2026 21:36:57 +0200 Subject: [PATCH] Add rustup for on-demand Rust support, document JS/TS development MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Install rustup-init binary from Rust CDN. Users bootstrap Rust with 'rustup-init -y' — persists via devbox-rustup and devbox-cargo volumes. Add JavaScript/TypeScript development docs (Node.js + npm in base, Bun in OMOS). --- DOCKER_HUB.md | 60 +++++++++++++++++++++++++++++++++++++++++++++- Dockerfile | 8 +++++++ README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++- docker-compose.yml | 7 ++++++ 4 files changed, 133 insertions(+), 2 deletions(-) diff --git a/DOCKER_HUB.md b/DOCKER_HUB.md index ac6a804..94f294e 100644 --- a/DOCKER_HUB.md +++ b/DOCKER_HUB.md @@ -185,6 +185,8 @@ Understanding what survives container restarts and what doesn't: | `/home/developer/.aws` | Host bind mount | ✅ Yes — lives on host | AWS credentials/SSO cache | | `/home/developer/.local/share/opencode` | Named volume (if configured) | ✅ Yes — Docker volume | Session history, memory, auth tokens | | `/home/developer/.local/share/uv` | Named volume (if configured) | ✅ Yes — Docker volume | Python installs, uv tool installs | +| `/home/developer/.rustup` | Named volume (if configured) | ✅ Yes — Docker volume | Rust toolchains | +| `/home/developer/.cargo` | Named volume (if configured) | ✅ Yes — Docker volume | Cargo binaries, registry cache | | `/home/developer/.config/opencode` | Host bind mount (if configured) | ✅ Yes — lives on host | opencode.json, oh-my-opencode-slim.json, skills | ### Key points @@ -193,6 +195,7 @@ Understanding what survives container restarts and what doesn't: - **opencode config** is auto-generated from `OPENCODE_PROVIDER` env var on each start if no existing config is found. To persist config changes, mount the config directory from the host (see Custom opencode Config below). - **opencode data** (session history, memory) is lost with `--rm` unless you add a named volume. - **Python installs** via `uv python install` are lost unless you add the `devbox-uv` named volume. +- **Rust toolchains** via `rustup-init` are lost unless you add the `devbox-rustup` and `devbox-cargo` named volumes. - **AWS SSO tokens** persist across restarts when `~/.aws` is mounted (recommended for Bedrock users). ## Custom opencode Config @@ -252,6 +255,56 @@ docker run -it --rm \ Project virtual environments (`.venv`) are stored in your workspace directory and persist automatically via the `/workspace` bind mount. +## Rust Development with rustup + +The image includes `rustup-init`, the Rust toolchain installer. Rust is not pre-installed but can be bootstrapped on demand: + +```bash +# One-time setup: install Rust toolchain (~300MB, persists with volumes) +rustup-init -y +source ~/.cargo/env + +# Now use Rust normally +cargo new my-project +cargo build +cargo run +``` + +To persist Rust toolchains and cargo data across container restarts, add named volumes: + +```bash +docker run -it --rm \ + -v devbox-rustup:/home/developer/.rustup \ + -v devbox-cargo:/home/developer/.cargo \ + ... \ + joakimp/opencode-devbox:latest +``` + +## JavaScript and TypeScript + +The base image includes **Node.js 22** and **npm** — sufficient for most JavaScript and TypeScript development: + +```bash +# Initialize a new project +npm init -y + +# Install dependencies +npm install + +# Run TypeScript (via tsx, ts-node, etc.) +npx tsx src/index.ts +``` + +The OMOS image variant also includes **Bun**, a faster JavaScript runtime and package manager: + +```bash +bun init +bun install +bun run src/index.ts +``` + +Node modules are stored in your project directory under `/workspace` and persist automatically. + ## Using docker-compose Create a directory with a `docker-compose.yml` and a `.env` file: @@ -291,6 +344,9 @@ services: - devbox-data:/home/developer/.local/share/opencode # Optional: persist Python/uv installs across restarts # - devbox-uv:/home/developer/.local/share/uv + # Optional: persist Rust toolchains and cargo data + # - devbox-rustup:/home/developer/.rustup + # - devbox-cargo:/home/developer/.cargo # Mount AWS config for Bedrock SSO (required for amazon-bedrock provider) # - ~/.aws:/home/developer/.aws # Optional: mount opencode config directory (persists config changes across restarts) @@ -303,6 +359,8 @@ services: volumes: devbox-data: # devbox-uv: + # devbox-rustup: + # devbox-cargo: ``` Docker Compose loads `.env` automatically from the same directory. All variables from `.env` are passed to the container via `env_file`. Do **not** hardcode provider settings in the `environment:` section — use `.env` instead. @@ -336,7 +394,7 @@ docker compose run --rm devbox bash # interactive shell - **opencode** — AI coding assistant - **Node.js 22** — for npx-based MCP servers - **AWS CLI v2** — SSO and Bedrock authentication -- **Dev tools** — git, git-lfs, ssh, ripgrep, fd, fzf, bat, eza, zoxide, uv, jq, make, curl, wget, neovim 0.12, tmux, htop, tree +- **Dev tools** — git, git-lfs, ssh, ripgrep, fd, fzf, bat, eza, zoxide, uv, rustup, jq, make, curl, wget, neovim 0.12, tmux, htop, tree - **Non-root user** — runs as `developer` with UID auto-matched to workspace owner (sudo available) ### OMOS image (`latest-omos`) diff --git a/Dockerfile b/Dockerfile index 6299814..53759da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -99,6 +99,14 @@ RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" rm -rf /tmp/uv-* && \ uv --version +# rustup — Rust toolchain manager +# Installs the rustup-init binary only. Users bootstrap Rust with: +# rustup-init -y && source ~/.cargo/env +# Toolchains persist via devbox-rustup and devbox-cargo volumes. +RUN ARCH=$(case "${TARGETARCH}" in amd64) echo "x86_64" ;; arm64) echo "aarch64" ;; *) echo "x86_64" ;; esac) && \ + curl -fsSL "https://static.rust-lang.org/rustup/dist/${ARCH}-unknown-linux-gnu/rustup-init" -o /usr/local/bin/rustup-init && \ + chmod +x /usr/local/bin/rustup-init + # Set locale RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen ENV LANG=en_US.UTF-8 diff --git a/README.md b/README.md index de76d6f..1ae749a 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ docker compose run --rm devbox - **MCP server support** — Node.js included for `npx`-based MCP servers - **Non-root user** — runs as `developer` with UID auto-matched to workspace owner (sudo available) - **Python via uv** — `uv` package manager included; install Python on demand with `uv python install` +- **Rust via rustup** — `rustup-init` included; bootstrap Rust on demand with `rustup-init -y` - **Optional runtimes** — Python (apt), Go via build args (Node.js always included — required for opencode v1.x) - **Multi-agent orchestration** — optional [oh-my-opencode-slim](https://github.com/alvinunreal/oh-my-opencode-slim) integration via build arg - **AWS CLI v2** — built-in SSO/Bedrock authentication with headless device-code flow @@ -172,6 +173,61 @@ volumes: Project virtual environments (`.venv`) are stored in your workspace directory and persist automatically via the `/workspace` bind mount. +### Rust development with rustup + +The image includes `rustup-init`, the Rust toolchain installer. Rust is not pre-installed but can be bootstrapped on demand: + +```bash +# One-time setup: install Rust toolchain (~300MB, persists with volumes) +rustup-init -y +source ~/.cargo/env + +# Now use Rust normally +cargo new my-project +cargo build +cargo run +``` + +To persist Rust toolchains and cargo data across container restarts, add named volumes to your `docker-compose.yml`: + +```yaml +volumes: + - devbox-rustup:/home/developer/.rustup + - devbox-cargo:/home/developer/.cargo + +volumes: + devbox-rustup: + devbox-cargo: +``` + +### JavaScript and TypeScript + +The base image includes **Node.js 22** and **npm** — sufficient for most JavaScript and TypeScript development: + +```bash +# Initialize a new project +npm init -y + +# Install dependencies +npm install + +# Run TypeScript (via tsx, ts-node, etc.) +npx tsx src/index.ts + +# Use npx for one-off tools +npx tsc --init +``` + +The OMOS image variant also includes **Bun**, a faster JavaScript runtime and package manager: + +```bash +bun init +bun install +bun run src/index.ts +``` + +Node modules are stored in your project directory under `/workspace` and persist automatically. + ### Rebuilding the Image `docker compose run` and `docker compose up` use the existing image — they **do not rebuild** when you change the Dockerfile or build args (e.g. updating `OPENCODE_VERSION`). Rebuild explicitly: @@ -345,7 +401,7 @@ Container (Debian bookworm) ├── opencode binary ├── oh-my-opencode-slim (optional — multi-agent orchestration plugin, includes Bun) ├── AWS CLI v2 (SSO + Bedrock auth) -├── neovim 0.12, tmux, htop, bat, eza, zoxide, uv, make +├── neovim 0.12, tmux, htop, bat, eza, zoxide, uv, rustup, make ├── git, ssh, ripgrep, fd, fzf, jq, curl, tree ├── Node.js (for MCP servers) ├── Bun (optional — included with oh-my-opencode-slim) @@ -362,6 +418,8 @@ Container (Debian bookworm) | `/home/developer/.aws` | Host bind mount (if configured) | ✅ Yes | AWS credentials/SSO cache | | `/home/developer/.local/share/opencode` | Named volume `devbox-data` | ✅ Yes | Session history, memory | | `/home/developer/.local/share/uv` | Named volume `devbox-uv` (if configured) | ✅ Yes | Python installs, uv tool installs | +| `/home/developer/.rustup` | Named volume `devbox-rustup` (if configured) | ✅ Yes | Rust toolchains | +| `/home/developer/.cargo` | Named volume `devbox-cargo` (if configured) | ✅ Yes | Cargo binaries, registry cache | | `/home/developer/.config/opencode` | Host bind mount (if configured) | ✅ Yes | opencode.json, oh-my-opencode-slim.json, skills | **opencode config** (`opencode.json`) is auto-generated from `OPENCODE_PROVIDER` on each start. It sets provider and model only — no MCP servers. To persist config changes and use custom settings, mount the config directory from the host (see Custom opencode config above). diff --git a/docker-compose.yml b/docker-compose.yml index 9f518bd..c8376c2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,9 +49,16 @@ services: # Without this, 'uv python install' must be re-run after container removal. - devbox-uv:/home/developer/.local/share/uv + # Optional: persist Rust toolchains and cargo data + # Without this, 'rustup-init' must be re-run after container removal. + # - devbox-rustup:/home/developer/.rustup + # - devbox-cargo:/home/developer/.cargo + # Optional: AWS credentials/SSO config (not read-only — SSO writes token cache) # - ~/.aws:/home/developer/.aws volumes: devbox-data: devbox-uv: + # devbox-rustup: + # devbox-cargo: