Skip to main content

Deploy a Rust App on Leapcell

Deploy your Rust app using the Axum framework on Leapcell in just a few steps. You can use our example app or deploy your own.

This serves as the simplest Rust deployment example. Other Rust examples can build upon this foundation.

1. Fork the Axum example on GitHub.

Here’s the main.rs file from that repository, borrowed from the official Axum documentation:

use axum::{response::Html, routing::get, Router};

#[tokio::main]
async fn main() {
// build our application with a route
let app = Router::new().route("/", get(handler));

// run it
let listener = tokio::net::TcpListener::bind("127.0.0.1:8080")
.await
.unwrap();
println!("listening on {}", listener.local_addr().unwrap());
axum::serve(listener, app).await.unwrap();
}

async fn handler() -> Html<&'static str> {
Html("<h1>Hello, World!</h1>")
}

2. Create a Service in the Leapcell Dashboard and connect your new repository.

Go to the Leapcell Dashboard and click the New Service button.

Then click Connect with GitHub and select the forked repository.

3. Provide the following values during creation:

info

Since Rust is a compiled language, we will use cargo build --release to build the Rust application.

In this example, our project name is app, so it will compile to ./target/release/app.

The start command should be ./target/release/app instead of cargo run --release. This is because cargo run writes .cache files, and the Leapcell environment does not support writing files in that path. For more details, see Service Storage.

If you are using your own app, make sure the command matches your project. Replace app with your project name and specify the correct start command (e.g., ./target/release/myapp).

FieldValue
RuntimeRust (Any version)
Build Commandcargo build --release
Start Command./target/release/app
Port8080

4. Access Your App:

Once deployed, you should see a URL like foo-bar.leapcell.dev on the Deployment page. Visit the domain shown on the service page.

Continuous Deployments

Every push to the linked branch automatically triggers a build and deploy. Failed builds are safely canceled, leaving the current version running until the next successful deploy.

Learn more about Continuous Deployments.