Frameworks

Deploy a Rust Rocket app

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

This guide deploys a minimal Rocket app. LILY detects Rust apps by their Cargo.toml. It reads the port from Rocket.toml.

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 rocket-demo and add these three files:

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

[dependencies]
rocket = "0.5"
Rocket.toml
[default]
address = "0.0.0.0"
port = 8000
src/main.rs
#[macro_use]
extern crate rocket;

#[get("/")]
fn hello() -> &'static str {
    "Hello from Rocket on LILY\n"
}

#[launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![hello])
}

The address 0.0.0.0 in Rocket.toml makes the app reachable inside LILY. Run it locally:

cargo run
curl localhost:8000
Hello from Rocket 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 rocket-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/rocket-demo @ main (origin)
  Project     rocket-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
Port8000/httpport = 8000 in Rocket.toml
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 Rocket 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 Rocket project to LILY with the lly CLI.
Check that Rocket.toml sets the address 0.0.0.0 and 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