Offload Rust compilation to a remote server. Build on a powerful machine, get binaries back locally.
- Local:
rsync,ssh, Rust toolchain - Remote:
sshserver, Rust toolchain (viarustup) - Passwordless SSH access (SSH keys) to the remote server
cargo install --git https://github.com/patrickjeremic/offloadOr from a local clone:
cargo install --path .Set the remote host via CLI flag or environment variable:
# Environment variable (supports user@host:port format)
export [email protected]:22
# Or pass it every time
offload --host [email protected] buildCompile on the remote server and copy binaries back:
offload build
offload build --release
offload build --bin my-binaryArtifacts are placed in target/offload/<target>/<profile>/.
Build remotely, then run the binary locally:
offload run
offload run --bin my-binary
offload run --release -- --config app.tomlrun-local is an alias for run.
Build and execute on the remote server. Supports SSH port forwarding:
offload run-remote
offload -L 8080 run-remote
offload -L 3000:8080 run-remote -- --releaseRun tests on the remote server:
offload test
offload test -- --libRun clippy on the remote server:
offload clippy
offload clippy -- -D warningsManage toolchains on the remote server:
offload toolchain install nightly
offload toolchain listRemove remote build directory and local target/offload/:
offload clean| Flag | Short | Description |
|---|---|---|
--host <HOST> |
-h |
SSH host (user@host or user@host:port) |
--port <PORT> |
-p |
SSH port (default: 22) |
--target <TRIPLE> |
Target triple (default: x86_64-unknown-linux-gnu) |
|
--env <KEY=VALUE> |
-e |
Environment variable for the remote cargo command (repeatable) |
--sync-git |
Include .git/ in the sync (for builds that run git) |
|
--copy-all-artifacts |
Copy the full target directory including deps/, build/, incremental/ |
|
--forward <SPEC> |
-L |
SSH port forward: port or local:remote (repeatable) |
offload picks up the project toolchain automatically:
rust-toolchain.toml([toolchain] channel = "...")rust-toolchain(plain text)- Local
cargo --versionas fallback
Override with +toolchain syntax:
offload +nightly build
offload +1.80.0 testrsyncsyncs source to/tmp/cargo-offload/<project>/on the remote- Toolchain and target are installed via
rustupif needed cargo <command>runs on the remote with the specified target- For
build/run, compiled artifacts are copied back viarsync
Use SSH connection multiplexing for faster repeated connections:
# ~/.ssh/config
Host build-server
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
ControlPersist 10m
MIT