Back to Shuttle

README

README.md

0.57.37.8 KB
Original Source
<!-- markdownlint-disable --> <p align="center"> </p> <p align="center"> <a href="https://github.com/shuttle-hq/shuttle/search?l=rust"> </a> <a href="https://docs.shuttle.dev/"> </a> <a href="https://docs.rs/shuttle-runtime"> </a> <a href="https://circleci.com/gh/shuttle-hq/shuttle/"> </a> </p> <p align="center"> <a href="https://crates.io/crates/cargo-shuttle"> </a> <a href="https://discord.gg/shuttle"> </a> <a href="https://twitter.com/shuttle_dev"> </a> </p> <p align="center"> <a href="https://console.algora.io/org/shuttle/bounties?status=open"> </a> <a href="https://console.algora.io/org/shuttle/bounties?status=completed"> </a> </p> <h1 align="center">Fastest Way to Build & Ship Rust Apps</h1> <div align="center"> Get resources and deploy your apps with a few lines of code. </div> <h3 align="center">Simple. &nbsp; Easy. &nbsp; Joyful.</h3> <p align="center"> <a href="https://github.com/shuttle-hq/shuttle/issues/new?assignees=&labels=S-Triage%2CT-Bug&projects=&template=BUG-REPORT.yml&title=%5BBug%5D%3A+">Report Bug</a> ยท <a href="https://github.com/shuttle-hq/shuttle/issues/new?assignees=&labels=S-Triage%2CT-Feature+Request&projects=&template=FEATURE-SUGGESTION.yml&title=%5BFeature%5D%3A+">Request a Feature</a> ยท <a href="https://discord.gg/shuttle">Join Our Discord</a> ยท <a href="https://x.com/shuttle_dev">Follow us on X</a> </p> <div align="center"></div>

<div align="center">โญ If you find Shuttle interesting, consider starring this repo to help spread the word.</div>

Features

  • One-line Resource Provisioning: Get a database or other resource by adding a single line of code to your main file. No config or yaml files required.
  • Rapid Development: It takes 2 minutes from project initialization to a deployed project. It takes seconds to provision a resource, and get it deployed to production.
  • First-class support for popular Rust frameworks: Axum, Actix Web, Rocket, and more
  • Security: Let us worry about the security & permissions while you focus on writing good code.

Quick Start

On Linux and macOS, you can use this install script, which will automatically install the correct target for your OS and distro:

sh
curl -sSfL https://www.shuttle.dev/install | bash

On Windows, you can use this install script to do the same:

powershell
iwr "https://www.shuttle.dev/install-win" | iex

After installing, log in with:

sh
shuttle login

To initialize your project, simply write:

bash
shuttle init --template axum hello-world

And to deploy it, write:

bash
cd hello-world
shuttle deploy

And... that's it!

text
Service Name:  hello-world
Deployment ID: 3d08ac34-ad63-41c1-836b-99afdc90af9f
Status:        running
Last Updated:  2022-04-01T08:32:34Z
URI:           https://hello-world.shuttleapp.rs

Feel free to build on top of the generated hello-world boilerplate or take a stab at one of our examples.

For the full documentation, visit our docs.

Quick Look

Below is a basic "Hello World" application written in Axum:

rust
use axum::{routing::get, Router};

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(hello_world));

    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    println!("listening on {}", listener.local_addr().unwrap());
    axum::serve(listener, app).await.unwrap();
}

async fn hello_world() -> &'static str {
    "Hello, world!"
}

In order to be able to deploy it with a single command, we update the snippet as follows:

rust
use axum::{routing::get, Router};

async fn hello_world() -> &'static str {
    "Hello, world!"
}

#[shuttle_runtime::main]
async fn main() -> shuttle_axum::ShuttleAxum {
    let router = Router::new().route("/", get(hello_world));

    Ok(router.into())
}

Now, with just shuttle deploy, you can see your application live. But let's enhance it further by adding a shared Postgres database:

rust
use axum::{routing::get, Router};

async fn hello_world() -> &'static str {
    "Hello, world!"
}

#[shuttle_runtime::main]
async fn main(
    #[shuttle_shared_db::Postgres] pool: sqlx::PgPool,
) -> shuttle_axum::ShuttleAxum {

    pool.execute(include_str!("../schema.sql"))
        .await
        .expect("failed to run migrations");

    let router = Router::new().route("/", get(hello_world));

    Ok(router.into())
}

Now, if we run shuttle deploy, we'll have an up and running project with a database inside & ready to use.

Repositories

NameDescription
shuttle ๐Ÿš€ (This repo)All library crates and the Shuttle CLI.
shuttle-examples ๐Ÿ‘จโ€๐ŸซOfficially maintained examples of projects that can be deployed on Shuttle.
shuttle-docs ๐Ÿ“ƒDocumentation hosted on docs.shuttle.dev.
www ๐ŸŒOur website shuttle.dev, including the blog and more.
deploy-action โš™GitHub Action for continuous deployments.
awesome-shuttle ๐ŸŒŸAn awesome list of Shuttle-hosted projects and resources that users can add to.
shuttlings โš”๏ธA collection of Rust code challenges. A great way to get started with using Rust and Shuttle.

Contributing to Shuttle

Contributing to Shuttle is highly encouraged! Even if you are not planning to submit any code, joining our Discord server and providing feedback helps us a lot!

Check out our contributing docs and find the appropriate repo above to contribute to. For development of this repo, check the development docs.

Algora Bounties ๐Ÿ’ฐ

To offload work from the engineering team on low-priority issues, we will sometimes add a cash bounty to issues. Sign up to the Algora Console to find open issues with bounties.

Contributors โœจ

Thanks goes to these wonderful people:

<!-- markdownlint-disable --> <a href="https://github.com/shuttle-hq/shuttle/graphs/contributors"> </a>

Made with contrib.rocks.

<!-- invisible -->