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

# Deploy a Rust app

> How Brimble builds and runs Rust services, and how to set install, build, and start commands correctly.

How Brimble builds and runs Rust services, and how to set install, build, and start commands so your app actually starts.

Detected via `Cargo.toml` at the project root (or root directory you set). Service type: **Web service** (or **Worker** if you choose that).

## Recommended setup

**Leave Install and Build empty.** Brimble's builder (Railpack) detects Rust and runs the right steps for you.

| Setting              | Value                                                                     |
| -------------------- | ------------------------------------------------------------------------- |
| **Install**          | Leave empty                                                               |
| **Build**            | Leave empty                                                               |
| **Start**            | Leave empty, or set `./bin/<app-name>`                                    |
| **Output directory** | Leave empty for defaults, or set where the binary should live (see below) |

What the builder does when install/build are empty:

1. Installs the Rust toolchain.
2. Compiles with `cargo build --release` (for workspaces: `cargo build --release --package <pkg>`).
3. Copies the binary from Cargo's output into `bin/` (or your **Output directory** if set).
4. Starts with `./bin/<app-name>` (or `./<output-directory>/<app-name>` if you set one).

`<app-name>` is the package name from `Cargo.toml` (e.g. `ringroad` → `./bin/ringroad`).

## Output directory

| Output directory            | Result                                                                    |
| --------------------------- | ------------------------------------------------------------------------- |
| **Empty**                   | Railpack defaults: binary at `./bin/<app-name>`, start `./bin/<app-name>` |
| **Set** (e.g. `bin`, `app`) | Binary is copied to `./<dir>/<app-name>` and start is set to that path    |

Cargo still builds into `target/release/` first. Output directory is where Brimble **places the runnable binary in the final image** — not a replacement for Cargo's build cache path.

## Why not `target/release`?

`cargo build --release` writes the binary to `target/release/<app-name>`. That is Cargo's normal output directory.

The **running image does not keep `target/`**. Build caches use it; the final container does not ship it. So a start command like:

```bash theme={null}
./target/release/ringroad
```

will fail with `No such file or directory` even when the build succeeded.

The binary that *is* in the image lives at:

```bash theme={null}
./bin/<app-name>
```

## Custom build command

If you need a custom **Build** (flags, features, workspace package), either:

1. **Set Output directory** (e.g. `bin`) and a **Start** like `./bin/<app-name>` — Brimble copies `target/release/<app-name>` into that directory for you, or
2. Copy yourself in the build command:

```bash theme={null}
cargo build --release && mkdir -p bin && cp target/release/<app-name> bin/
```

Workspace package example:

```bash theme={null}
cargo build --release -p <package> && mkdir -p bin && cp target/release/<app-name> bin/
```

Then set **Start** to `./bin/<app-name>` (or match your output directory).

A bare `cargo build --release` with no output directory and no `cp` leaves no runnable path in the image. The build can succeed and the container still cannot start.

## Install command

Optional. You can set `cargo fetch` if you want; it is not required when Build is empty.

## Listen on all interfaces

Your process must listen on `0.0.0.0` and the `PORT` env var Brimble injects (or the port you configure). Binding only to `127.0.0.1` will fail health checks. See [Application failed to respond](/troubleshooting/application-failed-to-respond).

## Checklist

* [ ] Prefer empty **Build** unless you have a reason to override.
* [ ] **Start** is `./bin/<app-name>`, not `./target/release/...`.
* [ ] If **Build** is custom, it ends with a copy into `bin/`.
* [ ] App binds to `0.0.0.0` and `$PORT`.
