Shuttle Documentation
repository·main·Indexed 27 days ago
https://github.com/shuttle-hq/shuttleA platform for building and shipping Rust applications with one-line resource provisioning. Shuttle handles infrastructure, security, and deployment via a specialized CLI and runtime. It supports web frameworks like Axum, Actix Web, and Poem, and provides plugins for provisioning Postgres, AWS RDS, Turso, and OpenDAL storage.
What's inside Shuttle
- Shuttle Shared Databases is a plugin that manages Postgres databases on the Shuttle platform. When using this resource, your database resides in a cluster shared with other users, but it remains isolated and inaccessible to them.
Integrate Poem with Shuttle
mainTo use the Poem web framework with Shuttle, use the
ShuttlePoemtype in your main function. Your main function should be annotated with#[shuttle_runtime::main]and return aShuttlePoem<impl poem::Endpoint>. You can convert a PoemRouteinto aShuttlePoemusing the.into()method.use poem::{get, handler, Route}; use shuttle_poem::ShuttlePoem; #[handler] fn hello_world() -> &'static str { "Hello, world!" } #[shuttle_runtime::main] async fn poem() -> ShuttlePoem<impl poem::Endpoint> { let app = Route::new().at("/", get(hello_world)); Ok(app.into()) }Initialize a new Shuttle project
mainYou can create a new project using a template. For example, to initialize a project with Axum boilerplate, use the
shuttle initcommand with the--templateflag.shuttle init --template axum my-axum-appWrite a custom Shuttle service integration
mainTo create a new service integration for Shuttle, you must implement theServicetrait for your framework. This allows your framework to be recognized and managed by the Shuttle runtime.Use Axum 0.7 with shuttle-axum
mainIf your project requires Axum 0.7 instead of the default Axum 0.8, you must disable default features for
shuttle-axumand explicitly enable theaxum-0-7feature flag in yourCargo.toml.axum = "0.7.3" shuttle-axum = { version = "...", default-features = false, features = ["axum-0-7"] }Set up the Shuttle development environment
mainTo develop Shuttle locally, clone the repository and initialize the linked examples submodule.
git clone git@github.com:shuttle-hq/shuttle.git cd shuttle git submodule init git submodule updateDeploy a Shuttle app to the cloud
mainDeploy your service to the Shuttle cloud using theshuttle deploycommand. Once deployed, your service will be accessible via a subdomain of*.shuttle.app.shuttle deployImplement custom resource plugins using ResourceInputBuilder
mainTo extend Shuttle with custom managed resources, you must implement the
ResourceInputBuildertrait. You can find implementation patterns by examining existing plugins in the repository or by reviewing the official custom resource examples in theshuttle-examplesrepository.https://github.com/shuttle-hq/shuttle-examples/tree/main/custom-resourceIntegrate Shuttle with the Salvo web framework
mainTo use Salvo with Shuttle, define your main function using the
#[shuttle_runtime::main]attribute and return ashuttle_salvo::ShuttleSalvotype. You can convert a SalvoRouterinto this type using the.into()method.use salvo::prelude::*; #[handler] async fn hello_world(res: &mut Response) { res.render(Text::Plain("Hello, world!")); } #[shuttle_runtime::main] async fn salvo() -> shuttle_salvo::ShuttleSalvo { let router = Router::new().get(hello_world); Ok(router.into()) }Install shuttle-opendal
mainTo use OpenDAL with your Shuttle service, add the
shuttle-opendalcrate to your dependencies using cargo:cargo add shuttle-opendalInstall the Shuttle CLI
mainInstall the Shuttle CLI to deploy Rust applications using a single command. Use the appropriate command for your operating system.
# Linux / macOS curl -sSfL https://www.shuttle.dev/install | bash # Windows (Powershell) iwr https://www.shuttle.dev/install-win | iexIntegrate Shuttle with the Rocket web framework
mainTo deploy a Rocket application on Shuttle, use the
shuttle_rocket::ShuttleRockettype as the return type for your#[shuttle_runtime::main]entry point. You can convert a standard Rocket instance into a Shuttle-compatible service using the.into()method.use rocket::{get, routes}; #[get("/")] fn index() -> &'static str { "Hello, world!" } #[shuttle_runtime::main] async fn rocket() -> shuttle_rocket::ShuttleRocket { let rocket = rocket::build().mount("/", routes![index]); Ok(rocket.into()) }