1. Create and deploy a Rust and Axum hello app
You will see a hello response at / and ok at /health before adding any services.
1. Download and run locally
Download the hello ZIP into a working directory, then open a terminal in that directory:
unzip rust-hello.zip
cd rust-hello
cargo build --locked
cargo run --locked
Keep it running. In another terminal, curl -fsS http://localhost:3000/health should print ok.
Open http://localhost:3000/ and confirm the hello message. Stop the server with Ctrl+C.
The app source is small enough to inspect in full:
Cargo.toml
[package]
name = "web"
version = "0.1.0"
edition = "2024"
[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["full"] }
rust-toolchain.toml
[toolchain]
channel = "1.99.0"
profile = "minimal"
src/main.rs
use axum::{Router, routing::get};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app = Router::new()
.route("/", get(|| async { "Hello from Rust on d2o!\n" }))
.route("/health", get(|| async { "ok\n" }));
let port = std::env::var("PORT").unwrap_or_else(|_| "3000".into());
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{port}")).await?;
axum::serve(listener, app).await?;
Ok(())
}
Keep the supplied lockfiles in Git. The buildpack uses these manifests and its runtime version declaration to reproduce the app’s dependencies.
2. Create the Environment
Dashboard: open Project Examples → create Environment rust, type Development,
branch main, release source Build, Automatic deployment on.
CLI:
paas envs create rust -o "$TUTORIAL_ORG" -p examples --type development --branch main --release-source build
3. Create the web app
Dashboard: inside rust choose Add Resource → Web Application.
Name it notes-web, choose Framework Rust,
Repository The environment’s shared repository, Directory blank (repository root),
and Process type web. Use Port 3000, Health Check Path /health, and one replica.
Click Create Resource.
CLI:
paas apps create notes-web --framework rust --shared-source --start-command web --port 3000 --health-check-path /health -o "$TUTORIAL_ORG" -p examples -e rust
4. Commit and push
Initialize a repository in the unpacked hello directory:
git init -b main
git add .
git commit -m "Add hello application"
Dashboard path: open the Environment’s Git remote panel, copy its shared-repository remote command into this directory, then run its push command. This is the Environment remote, not a per-app remote. The dashboard supplies the correct host and authentication URL.
CLI path: omit -a when setting the shared remote:
paas git remote -o "$TUTORIAL_ORG" -p examples -e rust
git push d2o main
paas watch -a notes-web -o "$TUTORIAL_ORG" -p examples -e rust
5. Verify the deployed app
Dashboard: open notes-web → Deployments, wait for the successful build and running
instance, then open its public URL. Append /health; it should display ok.
CLI: paas ps and paas logs with -o "$TUTORIAL_ORG" -p examples -e rust and -a notes-web show the running process.
Use the public URL displayed in the dashboard, or read the url field from
paas apps info notes-web --json with the same Organization, Project, and Environment flags.
APP_URL=https://your-app-host
curl -fsS "$APP_URL/health"
curl -fsS "$APP_URL/"
Set APP_URL to your actual URL, with no trailing slash. If the build fails, see
troubleshooting before continuing.
Next: Persist notes in PostgreSQL.