Frameworks

Deploy a Rust Axum app

Deploy an Axum app on LILY from a GitHub repository, with the CLI or the console.

This guide deploys a minimal Axum web server. LILY detects Rust apps by their Cargo.toml and finds the port in your code.

Before you start

  • A LILY account with GitHub connected, and the lly CLI installed and signed in. See the Quickstart.
  • Rust and Cargo, to run the app locally.

1. Create the app

Create a project with cargo new axum-demo and replace these two files:

Cargo.toml
[package]
name = "axum-demo"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["macros", "rt-multi-thread", "net"] }
src/main.rs
use axum::{routing::get, Router};

async fn hello() -> &'static str {
    "Hello from Axum on LILY\n"
}

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(hello));
    let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

Bind to 0.0.0.0, not 127.0.0.1, so the app is reachable inside LILY. Run it locally:

cargo run
curl localhost:3000
Hello from Axum on LILY

2. Push it to GitHub

LILY builds from GitHub, not from your local files.

git init -b main
git add -A && git commit -m "First commit"
gh repo create axum-demo --private --source=. --push

Any way of creating the GitHub repository works. LILY needs your GitHub account connected to read a private repository.

3. Deploy

Run this in the project directory:

lly deploy

No flags are needed.

lly detects the app, builds it and follows the build until it is live. The output, shortened:

  Repository  acme/axum-demo @ main (origin)
  Project     axum-demo (new)
  ✓ Source      1 root detected

  Detected roots
       Root  Framework  Status  Hint
    *  .     rust       ok      Cargo.toml

  ✓ Analyzed
    copperfox      deployed   3m10s

  Apps
    App        Phase     URL                             Since  Note
    copperfox  deployed  https://copperfox.lilylabs.app  in 0s

Start a new project, pick the repository and follow the steps in Deploy an app. LILY lists the app with the framework rust.

What LILY detected

SettingValueFrom
FrameworkrustCargo.toml
Port3000/httpbind("0.0.0.0:3000") in src/main.rs
Public accessYesAn app with a detected port is public
Environment variablesNoneThe app reads none

Check that it worked

curl https://copperfox.lilylabs.app
Hello from Axum on LILY

Use the address from the summary in place of copperfox.lilylabs.app.

Known limits

None found with this app. It deployed and answered without changes.

Use an agent

Deploy this Axum project to LILY with the lly CLI.
Check that the server binds to 0.0.0.0 with a fixed port and that the branch is pushed to GitHub.
Run `lly deploy -y --json` from the project root. When it is live, request the URL and show me the response.
If it exits with code 7, show me the build log with `lly attach <slug> --build`.

Next steps

On this page