Skip to content

Quick Start — Rust

Deploy a Rust app (axum, actix, rocket, hyper) from git push to a live HTTPS URL in 5 minutes.

Prerequisites

  • A Rust project with Cargo.toml
  • Rust 1.75+ on your machine (rustc --version)
  • The paas CLI:
    curl -fsSL https://get.di2amp.com/install.sh | sh
    paas --version
    

Scaffold (if you don't have a project yet)

cargo new hello-paas --bin && cd hello-paas
cat > Cargo.toml <<'EOF'
[package]
name = "hello-paas"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.7"
tokio = { version = "1", features = ["full"] }
EOF
cat > src/main.rs <<'EOF'
use axum::{routing::get, Router};
use std::net::SocketAddr;

#[tokio::main]
async fn main() {
    let port: u16 = std::env::var("PORT")
        .unwrap_or_else(|_| "8080".to_string())
        .parse()
        .expect("PORT must be a number");
    let app = Router::new().route("/", get(|| async { "Hello from PaaS Runtime!\n" }));
    let addr = SocketAddr::from(([0, 0, 0, 0], port));
    println!("listening on :{port}");
    axum::serve(tokio::net::TcpListener::bind(addr).await.unwrap(), app)
        .await
        .unwrap();
}
EOF
git init && git add -A && git commit -m "init"

Step 1 — Authenticate

paas login

Verify:

$ paas whoami
octave@paas.local (member of: paas-default)

Step 2 — Create the app

paas apps create hello-paas

Output:

✓ Created app hello-paas
  URL:    https://hello-paas.runtime.di2amp.com
  Region: eu-fr-1
  Plan:   free
  Git:    https://git.di2amp.com/octave/hello-paas.git

Step 3 — Add a Procfile

The Paketo Rust buildpack auto-detects Cargo.toml and runs cargo build --release. Declare the binary in Procfile:

# Procfile
web: ./target/release/hello-paas

Commit:

git add Procfile && git commit -m "add Procfile"

Step 4 — Push to deploy

git push paas main

Live build logs:

remote: ─────── PaaS Build ───────
remote: → Detected: rust (paketo-buildpacks/rust)
remote: → Installing Rust 1.78.0 (rustup)
remote: → Running: cargo build --release --bin hello-paas
remote: → Image:    registry.di2amp.com/octave/hello-paas:abc1234
remote: → Image size: 18 MB (release binary stripped, distroless base)
remote: → SBOM:     ✓ generated, 47 packages
remote: → CVE scan: ✓ 0 critical, 0 high
remote:
remote: ─────── PaaS Deploy ───────
remote: → Process types: web
remote: → Replicas:      1/1 ready
remote: → Rollout:       v1 → v2 (canary 10% → 100%)
remote: → Health:        / returns 200 OK
remote: → URL:           https://hello-paas.runtime.di2amp.com
remote:
remote: ✓ Deployed in 92s   (Rust builds are slower; subsequent builds use cargo cache)

The first build takes 60–120s because of cargo dependency compilation. Subsequent pushes leverage cargo's incremental cache (≈20s).

Step 5 — Verify the app is live

$ curl https://hello-paas.runtime.di2amp.com/
Hello from PaaS Runtime!

Dashboard runtime status:

https://ma30.di2amp.com/runtime/dashboard/apps/hello-paas

Next steps

Add a managed PostgreSQL

paas addons create database --type postgres --plan free --name db

DATABASE_URL is injected:

use sqlx::postgres::PgPoolOptions;

let pool = PgPoolOptions::new()
    .connect(&std::env::var("DATABASE_URL")?)
    .await?;

Tail logs

paas logs --tail

Speed up cold starts

Set RUST_LOG=info and avoid panic-on-startup. Add a /healthz endpoint that returns 200 fast — PaaS uses it for readiness probes.

Cross-compile for aarch64 (free plan)

The free plan runs on aarch64 nodes by default. Paketo auto-targets the host arch — no flags needed. To force x86_64:

paas config:set BP_RUST_TARGET=x86_64-unknown-linux-gnu

Scale processes

paas ps:scale web=3

See also