Deploy by framework

Rust

Deploy a Cargo-built Rust HTTP server with a managed container and optional public CDN assets.

Nitroship detects a runnable Rust package from Cargo.toml and its binary targets. The managed preset builds a release binary and packages it in a runtime image. Your HTTP server handles dynamic pages and APIs on compute; an optional public/ folder is served from the CDN.

Deploy

Install the CLI

curl -fsSL https://nitroship.co/install.sh | bash
ntro login

Already installed? Skip ahead. Full options, PATH setup, and updates: Install the CLI.

Choose a compute region; there is no default. Select Rust explicitly in the deployment root:

nitroship.json
{
  "build": {"framework": "rust"},
  "compute": {"regions": ["kr-icn"]}
}
ntro apps create my-rust-app
ntro deploy . --prod

This preset requires the hosted builder. Remove --local from your deploy command. After deploying, open an HTTP route and, if present, a public asset at the URL printed by the CLI.

Cargo project and binary selection

Commit Cargo.toml and Cargo.lock. Toolchain selection reads the channel in rust-toolchain.toml, then rust-toolchain, then .tool-versions. The build uses a pinned supported toolchain/base nearest your declared version, or a stable default without a declaration.

The deployment root must be a Cargo package with a runnable binary. The preset recognizes src/main.rs, [[bin]] declarations, src/bin/*.rs, and src/bin/*/main.rs. A package with one binary is selected automatically. If there are several, set the package's default-run to the binary you want:

Cargo.toml
[package]
name = "my-server"
version = "0.1.0"
edition = "2021"
default-run = "my-server"

A library-only package, ambiguous binaries without default-run, or a workspace-only root cannot be deployed as a managed server. Deploy a package root or use your own Dockerfile for workspace builds, native libraries, or a custom binary selection. The preset builds the selected binary in release mode; it does not invent an HTTP server for a CLI application.

Listen on the managed port

Your application must listen on 0.0.0.0:$PORT, with 3000 when PORT is unset. The image cannot rewrite an arbitrary Rust application's bind address. For example, derive the address before passing it to your web framework:

let port = std::env::var("PORT").unwrap_or_else(|_| "3000".to_owned());
let address = format!("0.0.0.0:{port}");

Do not bind only to localhost or hard-code another port.

Static assets

When public/ exists, it is included at /app/public and public files are staged under /nitroship/static. The builder automatically extracts that directory to the CDN root before starting the runtime. public/logo.svg becomes /logo.svg; .rs files and other server source must stay out of CDN output.

Without public/, this preset produces no static CDN output. Files embedded in the binary are not automatically extracted, and all requests go to compute. Use a public folder or a custom Dockerfile for a different static layout.

Environment and runtime limits

Use Environment variables for secrets and application/database settings. DATABASE_URL works only if your application reads it. Connect to an external database for durable data.

Generated images run as a non-root user. The instance filesystem is ephemeral; use /tmp for temporary writes only. Store uploads in S3 or other object storage instead of the image or public/.

Nitroship does not automatically run migrations, queue workers, or schedulers. Run your project's database migration command in CI or locally against the external database, and run workers separately. Use Cron jobs for scheduled HTTP work rather than an in-process scheduler.

Framework selection and Dockerfile escape hatch

build.framework: "rust" selects Rust explicitly and overrides an automatically found Dockerfile. It cannot coexist with build.dockerfile.

Without an explicit framework, Nitroship detects the build as described in How Nitroship chooses a build. For native libraries, workspace builds, or custom build/runtime commands, remove build.framework and use your own Dockerfile.

On this page