skills/rust-deploy/SKILL.md
Build and deploy Rust applications — version detection, release binaries, cargo-chef, and Dockerfile patterns. Use when deploying a Rust project, or when Cargo.toml is detected.
npx skillsauth add nixopus/agent rust-deployInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Project is Rust if Cargo.toml or cargo.toml exists.
Rust version priority:
rust-toolchain.toml → toolchain.channelCargo.toml → package.rust-version.rust-version fileCargo.toml → package.edition (maps to minimum Rust version)cargo build --releasetarget/release/<package-name>Cargo.toml → [package].namesrc/main.rssrc/bin/<name>.rs → binary name matches filename[bin] section in Cargo.tomltarget/release/<name>./bin/<project-name> or ./target/release/<name>| Variable | Purpose |
|---|---|
| ROCKET_ADDRESS | Rocket bind address (use 0.0.0.0 for containers) |
| PORT | Port for web servers (default 8080) |
PORT in .env / .env.example:8080, bind, TcpListener in main.rs| Crate | Category |
|---|---|
| axum | Web |
| actix-web | Web |
| rocket | Web |
| warp | Web |
| tokio | Async runtime |
| tower | Middleware |
Copy in order:
Cargo.toml, Cargo.locksrc/ (or full source)| Cache key | Path |
|---|---|
| cargo_registry | ~/.cargo/registry |
| cargo_git | ~/.cargo/git |
| cargo_target | target/ |
| Stage | Image |
|---|---|
| Build | rust:1.89-bookworm or rust:1.89-alpine |
| Runtime | debian:bookworm-slim or gcr.io/distroless/cc |
For Alpine build: may need musl-dev for fully static binary.
FROM rust:1.89-bookworm AS build
WORKDIR /app
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release
COPY src ./src
RUN touch src/main.rs && cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/target/release/<binary-name> .
EXPOSE 8080
CMD ["./<binary-name>"]
FROM rust:1.89-bookworm AS chef
RUN cargo install cargo-chef
FROM chef AS planner
WORKDIR /app
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS build
WORKDIR /app
COPY --from=planner /app/recipe.json .
RUN cargo chef cook --release --recipe-path recipe.json
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/target/release/<binary-name> .
EXPOSE 8080
CMD ["./<binary-name>"]
FROM rust:1.89-bookworm AS build
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /app/target/release/<binary-name> .
EXPOSE 8080
CMD ["./<binary-name>"]
main.rs trick (echo "fn main() {}" > src/main.rs) caches dependency compilation, but touch src/main.rs is needed afterward to invalidate the binary build cacheCargo.lock must be committed for binary crates — without it, dependency versions are resolved fresh on every buildmusl-dev, but crates using OpenSSL also need openssl-dev and pkgconfigcargo build --release -j 2 limits parallelism to avoid OOM kills in resource-constrained environmentsprepare requires the full source tree — it scans code to compute the dependency recipetools
Compressed catalog of all Nixopus API operations for the nixopus_api() tool
development
Deploy static file sites — Caddy/nginx serving, Staticfile config, and Dockerfile patterns. Use when deploying a static HTML site with no server-side runtime, or when index.html or a Staticfile is detected at the project root.
devops
Deploy shell script applications — interpreter detection, setup scripts, and Dockerfile patterns. Use when deploying a shell script project, or when start.sh is detected.
development
Self-healing loop for failed deployments — diagnose, fix, redeploy up to 3 attempts, then escalate or rollback. Load when a deployment fails or build errors occur.