cargo-shuttle
brings shuttle, the open source serverless platform for Rust web applications, into your terminal. With a dedicated focus on productivity, reliability, and performance, cargo-shuttle
makes deploying your code to the cloud as easy as deriving a trait.
cargo-shuttle
is available for macOS, Linux, and Windows. To install the commandline tool, run:
bash
cargo install cargo-shuttle
cargo-shuttle
's subcommands help you build and deploy web apps from start to finish.
Run cargo shuttle help
to see the basic usage:
```text
Usage: cargo-shuttle [OPTIONS]
Commands: deploy deploy a shuttle service deployment manage deployments of a shuttle service init create a new shuttle service generate generate shell completions status view the status of a shuttle service logs view the logs of a deployment in this shuttle service clean remove artifacts that were generated by cargo stop stop this shuttle service secrets manage secrets for this shuttle service login login to the shuttle platform logout log out of the shuttle platform run run a shuttle service locally feedback Open an issue on github and provide feedback project manage a project on shuttle help Print this message or the help of the given subcommand(s)
Options:
--api-url
init
To initialize a shuttle project with boilerplates, run cargo shuttle init [OPTIONS] [PATH]
.
Currently, cargo shuttle init
supports the following frameworks:
--actix-web
: for actix web framework--axum
: for axum framework--poem
: for poem framework--poise
: for poise discord bot framework--rocket
: for rocket framework--salvo
: for salvo framework--serenity
: for serenity discord bot framework--thruster
: for thruster framework--tide
: for tide framework--tower
: for tower library--warp
: for warp frameworkFor example, running the following command will initialize a project for rocket:
sh
cargo shuttle init --rocket my-rocket-app
This should generate the following dependency in Cargo.toml
:
toml
shuttle-service = { version = "0.11.0", features = ["web-rocket"] }
The following boilerplate code should be generated into src/lib.rs
:
```rust
extern crate rocket;
fn index() -> &'static str { "Hello, world!" }
async fn rocket() -> shuttle_service::ShuttleRocket { let rocket = rocket::build().mount("/hello", routes![index]);
Ok(rocket)
} ```
run
To run the shuttle project locally, use the following command:
```sh
cargo shuttle run ```
This will compile your shuttle project and start it on the default port 8000
. Test it by:
sh
$ curl http://localhost:8000/hello
Hello, world!
login
Use cargo shuttle login
inside your shuttle project to generate an API key for the shuttle platform:
```sh
cargo shuttle login ```
This should automatically open a browser window with an auto-generated API key for your project. Simply copy-paste the API key back in your terminal or run the following command to complete login:
sh
cargo shuttle login --api-key <your-api-key-from-browser>
deploy
To deploy your shuttle project to the cloud, run:
sh
cargo shuttle project new
cargo shuttle deploy
Your service will immediately be available at {crate_name}.shuttleapp.rs
. For instance:
sh
$ curl https://my-rocket-app.shuttleapp.rs/hello
Hello, world!
status
Check the status of your deployed shuttle project with:
sh
cargo shuttle status
logs
Check the logs of your deployed shuttle project with:
sh
cargo shuttle logs
stop
Once you are done with a deployment, you can stop it by running:
sh
cargo shuttle stop
Thanks for using cargo-shuttle
! Weβre very happy to have you with us!
During our alpha period, API keys are completely free and you can deploy as many services as you want.
Just keep in mind that there may be some kinks that require us to take all deployments down once in a while. In certain circumstances we may also have to delete all the data associated with those deployments.
To contribute to cargo-shuttle
or stay updated with our development, please open an issue, discussion or PR on Github and join our Discord! π