Skip to main content

Shuttle

What's Shuttle?​

Shuttle is a Rust-native cloud development platform that lets you deploy your Rust apps for free.

Using Graphul we can have an easy deployment with Shuttle.

As Graphul is based on the top of Axum we share the possibility to reutilize the same method of deployment that Axum.

Here is the original guide to deploy a service using Axum

Zero to production​

Shuttle provides a CLI to ease the deployment.

info

In the most recent versions of Shuttle you will require to install Protoc/Protobuff-Compiler before the CLI.

We recommend checking this documentation to do it.

So to start we need to install the CLI.

cargo install cargo-shuttle

And then login:

cargo shuttle login

Make a directory and enter in it:

mkdir your_project && cd your_project

You can start a new project using:

cargo shuttle init

You need to answer some questions about your project, when the CLI will ask you for a web framework to use choose none, we are going to configure it from zero.

However, in the project folder, we need to add the crate shuttle-axum and install too tokio as dependencies with the next command:

cargo add tokio shuttle-axum

And as expected we need to install Graphul, but just Graphul in this case:

cargo add graphul

Make sure that your Cargo.toml file looks like the one below -- having the right dependencies is key!

[package]
name = "graphul-testing"
version = "0.1.0"
edition = "2021"
publish = false

[dependencies]
shuttle-runtime = "0.12.0"
shuttle-axum = { version = "0.12.0" }
tokio = { version = "1.26.0" }
graphul = "0.5.6"

And then you need to replace your main.rs for this:

use graphul::{Graphul, http::Methods};

#[shuttle_runtime::main]
async fn axum() -> shuttle_axum::ShuttleAxum {
let mut app = Graphul::new();

app.get("/", || async { "Hello World 👋!" });

Ok(app.export_routes().into())
}

So now finally we need to deploy it using the following command:

cargo shuttle deploy

And your app is live! Congrats! 🎉🎉🎉