guides
Deploy a Rust App
Deploy a Rust web application to Runix — Actix-web, Axum, Rocket, or any HTTP server.
Rust apps deliver incredible performance and reliability. Runix detects your Cargo.toml, builds your project in a multi-stage Docker build, and deploys a tiny, optimized binary.
Prerequisites#
- A Rust project with a Cargo.toml file
- A Runix account (sign up free at runixcloud.dev)
Example: Axum App#
Here's a simple Axum web server. Runix works with any Rust HTTP framework — Actix-web, Axum, Rocket, Warp, or even a raw hyper server.
[package]
name = "my-rust-app"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["full"] }use axum::{routing::get, Router};
use std::env;
#[tokio::main]
async fn main() {
let port = env::var("PORT").unwrap_or_else(|_| "8080".to_string());
let addr = format!("0.0.0.0:{}", port);
let app = Router::new()
.route("/", get(|| async { "Hello from Runix!" }));
println!("Server running on {}", addr);
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(listener, app).await.unwrap();
}Configuration#
name: my-rust-app
services:
- name: api
type: web-service
repo: https://github.com/yourname/my-rust-app
branch: mainHow It Works#
- 1.Runix detects Rust from your Cargo.toml
- 2.It generates a multi-stage Dockerfile: a build stage with the full Rust toolchain and a runtime stage with just your binary
- 3.Your app is compiled in release mode with optimizations
- 4.The final image contains only the compiled binary — typically 10-30MB
- 5.Your app is deployed with a public HTTPS URL
Rust builds take longer than most languages — typically 1 to 3 minutes — because of compilation time. This is normal. Subsequent deploys are faster thanks to Docker layer caching.
Environment Variables#
| Variable | Set By | Description |
|---|---|---|
| PORT | Runix (automatic) | The port your app should listen on |
Common Issues#
Binary name mismatch#
Runix looks for a binary name matching your package name in Cargo.toml. If your [package] name uses hyphens (e.g., my-rust-app), Cargo produces a binary named my_rust_app (with underscores). The generated Dockerfile accounts for this, but if you use a custom [[bin]] target, make sure the name is correct.
# If you have a custom binary name, Runix will detect it:
[[bin]]
name = "server"
path = "src/main.rs"Not listening on 0.0.0.0#
Like other languages, your Rust app must listen on 0.0.0.0, not 127.0.0.1. Binding to 127.0.0.1 inside a container means nothing outside the container can reach it.
// Good
let addr = format!("0.0.0.0:{}", port);
// Bad - container-only access
let addr = format!("127.0.0.1:{}", port);