Skip to main content
The Rust preset runs any Rust web app that builds with Cargo, has Cargo.toml at the top level and listens on 0.0.0.0:8080. It works with frameworks like Axum, Actix Web and Rocket. Laravel Rust is supported too and gets extra setup. Your project is built on the pod in release mode, and the program runs as a systemd service.
The Rust preset is in beta. It needs the Build plan (2 GB of memory) or higher, because compiling Rust takes more memory than Launch has. It isn’t available on a free trial pod.

What’s Included

How Your App Runs

  • App root: /home/instapod/app. Your Cargo.toml must be here, at the top level.
  • App port: 8080
  • Program: /home/instapod/.app-bin/app, copied there after each successful build
  • Runs as the instapod user, starts on boot, restarts on a crash
These variables are set for your app: PORT=8080, HOST=0.0.0.0, ROCKET_PORT=8080 and ROCKET_ADDRESS=0.0.0.0.
Your app must listen on 0.0.0.0, port 8080. An app on 127.0.0.1 or localhost can’t be reached from the public URL.

The Build Step

Every deploy (git, instapods deploy, ZIP upload, pods reload) runs these steps:
  1. Front end. When package.json has a build script, its packages are installed and the script runs. npm, pnpm, Yarn and Bun are supported.
  2. Compile. cargo build --release.
  3. Install. The new program is copied into place and the service restarts.
If any step fails, the deploy fails with the error and your previous program keeps running.

How long it takes

A first build compiles every crate you use. On the Build plan, a small Axum app takes about 35 seconds. Laravel Rust takes about 5 minutes, and can take up to 10. Later deploys reuse the target/ folder and usually finish in under a minute. One build may take up to 30 minutes. target/ is kept between deploys. It is left out of backups, and it is emptied before a build when it passes 6 GB.

Which program runs

The program is read from Cargo.toml. If your project builds several, name the one to run:
In a workspace, also list that crate in default-members.

Custom build command

You can replace the build in the pod’s Git settings. End your command by copying the program to /home/instapod/.app-bin/app.new. InstaPods then puts it in place and restarts the app:

Deploying Your App

A repo with a Cargo.toml at its top level is detected as Rust. A repo that also has a package.json or composer.json is Rust when it depends on a web framework such as Axum, or has a program to run (src/main.rs, [[bin]] or default-run). A Node package with a Rust add-on (napi-rs, Neon) and a Tauri app stay Node.js, and a Python package built with maturin stays Python. Pass --preset to override.
instapods deploy from a folder detects Rust from CLI v1.19.0. On an older CLI, pass --preset rust.

Example App

Laravel Rust

An app that depends on the laravel-rust crate gets its settings written to .env on each deploy: When Cargo.toml turns on database-postgres or database-mysql and the pod has no such database, it is installed on the first deploy. migrate --force runs after each build when DATABASE_URL is set, but not on a rollback. If a migration fails, the deploy fails and the old program keeps running. Set your own release command in the pod’s Git settings to replace it.
Laravel Rust answers 400 Bad Request to any domain except the one in APP_URL and its subdomains. When you add a custom domain, run instapods env set my-rust-app APP_URL=https://example.com. The app restarts with the new value. The pod’s own instapods.app address then answers 400. Once your domain is connected to the pod, instapods deploy and pods reload check your domain instead. To serve several domains, list them with trust_hosts in your app.

Queue worker

A worker runs your queued jobs. It is a systemd service called app-worker that runs queue:work. Your next deploy or reload sets it up, and it restarts whenever the app does.
Scheduled tasks (schedule:work) are not started for you.

Adding a Database

Limits

  • The Cargo project must be at the top level of the repo. The subdirectory setting (--subdir) doesn’t change that.
  • A Dockerfile in the repo is not used.
  • Crates that need a system library other than OpenSSL don’t build until you install it in the pod with apt-get.

Viewing Logs