Shuttle is a serverless platform for Rust which makes it really easy to deploy your web-apps.
Shuttle is built for productivity, reliability and performance:
First download the Shuttle cargo extension and login:
$ cargo install cargo-shuttle
$ cargo shuttle login
$ cargo init --lib hello-world
Update your Cargo.toml
:
[package]
name = "hello-world"
version = "0.1.0"
edition = "2021"
[lib]
[dependencies]
rocket = "0.5.0-rc.1"
shuttle-service = { version = "0.3.3", features = ["web-rocket"] }
Create your first shuttle app in lib.rs
:
#[macro_use]
extern crate rocket;
use rocket::{Build, Rocket};
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
#[shuttle_service::main]
async fn rocket() -> Result<Rocket<Build>,shuttle_service::Error> {
let rocket = rocket::build().mount("/hello", routes![index]);
Ok(rocket)
}
Deploy:
$ cargo shuttle deploy
Finished dev [unoptimized + debuginfo] target(s) in 1m 01s
Project: hello-world
Deployment Id: 3d08ac34-ad63-41c1-836b-99afdc90af9f
Deployment Status: DEPLOYED
Host: hello-world.shuttleapp.rs
Created At: 2022-04-01 08:32:34.412602556 UTC
Database URI: postgres://***:***@pg.shuttle.rs/db-hello-world
For the full documentation, visit docs.rs/shuttle-service
If you want to setup a local environment to test code changes to core shuttle
packages, follow these steps.
Build the required images with
$ docker buildx bake -f docker-bake.hcl provisioner backend
The images get build with cargo-chef and therefore support incremental builds (most of the time). So they will be much faster to re-build after an incremental change in your code - should you wish to deploy it locally straightaway.
Create a docker persistent volume with
$ docker volume create shuttle-backend-vol
Finally, you can start a local deployment of the backend with
$ docker compose -f docker-compose.dev.yml up -d
The API is now accessible on localhost:8000
(for app proxies) and localhost:8001
(for the control plane). When running cargo run --bin cargo-shuttle
(in a debug build), the CLI will point itself to localhost
for its API calls. The deployment parameters can be tweaked by changing values in the .env file.
In order to test local changes to the shuttle-service
crate, you may want to add the following to a .cargo/config.toml
file:
[patch.crates-io]
shuttle-service = { path = "[base]/shuttle/service" }
See Overriding Dependencies for more.
For a comprehensive view of the shuttle roadmap check out this project board.
If you have any requests or suggestions feel free to open an issue.
We are currently in Public Alpha. Watch "releases" of this repo to get notified of major updates!