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.

info

You’ll need a GitHub account to proceed. If you don’t have one, you can create on the GitHub website.

1. Fork the Axum example on GitHub.

Repo: Axum example

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.

On the "New Service" page, select the repository you just forked.

tip

To access your repositories, you’ll need to connect Leapcell to your GitHub account.

Follow these instructions to connect to GitHub.

Once connected, your repositories will appear in the list.

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

Enter these values in the corresponding fields.

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.