> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Run a Rocket App

Getting an application running on Fly.io is essentially working out how to package it as a deployable image. Once packaged, it can be deployed to the Fly.io platform.

In this guide we’ll learn how to deploy a [Rocket](https://rocket.rs/) application on Fly.io.

Rocket is a web framework for Rust that makes it simple to write fast, type-safe, secure web applications with incredible usability, productivity and performance.

Launching a Rocket app on Fly.io is painless! With the help of the [cargo chef](https://github.com/LukeMathWalker/cargo-chef), we get great build times and small images.

## *Speedrun*

First, [install flyctl](/flyctl/install), the Fly.io CLI, and [sign up to Fly.io](/getting-started/sign-up-sign-in#first-time-or-no-fly-account-sign-up-for-fly) if you haven't already.

The fastest way to get a basic Rocket server on Fly.io is to use our rocket template:

```sh theme={null}
git clone --single-branch --branch rocket git@github.com:superfly/rust-templates.git rocket-app
cd rocket-app
fly launch --generate-name
```

## *Deploy a Rocket App from scratch*

If you don’t already have an existing Rocket application, you can create one with `cargo`:

```sh theme={null}
cargo new rocket-on-fly
cd rocket-on-fly
```

Then we have to add the `rocket` dependency to the project:

```bash theme={null}
cargo add rocket
```

Now, let's create a simple app in `src/main.rs`:

```rust theme={null}
#[macro_use] extern crate rocket;

#[get("/")]
fn index() -> &'static str {
    "Hello from fly.io!"
}

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

This will display a "Hello from fly.io!" message when you visit the root URL.
Take note that we serve the app on host `127.0.0.1` and port `8000`, these are the defaults for `rocket`. When deploying the app these defaults will be overridden using environment variables which you can find in the `fly.toml`.

We can confirm everything works fine by running `cargo run` and checking out `http://localhost:8000`.

And with that you can deploy the app!

<CodeGroup>
  ```bash cmd theme={null}
  fly launch
  ```

  ```output output theme={null}
  Scanning source code
  Detected a Rocket app
  Warning: This organization has no payment method, turning off high availability
  Creating app in [redacted]/rocket-on-fly
  We're about to launch your app on Fly.io. Here's what you're getting:

  Organization: Your Name              (fly launch defaults to the personal org)
  Name:         [app-name]             (derived from your directory name)
  Region:       Amsterdam, Netherlands (this is the fastest region for you)
  App Machines: shared-cpu-1x, 1GB RAM (most apps need about 1GB of RAM)
  Postgres:     <none>                 (not requested)
  Redis:        <none>                 (not requested)
  Sentry:       false                  (not requested)

  ...

  ==> Building image
  ...
  ==> Building image with Docker
  ...

  Watch your deployment at https://fly.io/apps/[app-name]/monitoring
  ...

  Visit your newly deployed app at https://[app-name].fly.dev/
  ```
</CodeGroup>

This will generate a `fly.toml` file with the configuration for your app and a Dockerfile that uses [cargo chef](/rust/the-basics/cargo-chef).
Refer to the [fly.toml docs](/reference/configuration) for more configuration options.

To deploy a new version of your app, simply run `fly deploy` in the project directory.

You can check out the full (yet minimal) example in [this GitHub repository](https://github.com/superfly/rust-templates) for a reference.
