Skip to content

Commit

Permalink
feat: project structure, custom binary name, welcome page update (#203)
Browse files Browse the repository at this point in the history
* intro links

* feat: add project structure doc
  • Loading branch information
jonaro00 authored Oct 19, 2023
1 parent 17e230d commit e247a95
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 36 deletions.
6 changes: 3 additions & 3 deletions configuration/project-name.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: "Shuttle Project Name"
description: "How project names work"
title: Project name
description: How Shuttle project names work
---

Your Shuttle Project Name determines which subdomain your project is hosted on (`https://<project-name>.shuttleapp.rs/`).
Expand Down Expand Up @@ -48,4 +48,4 @@ This will create a new Axum-based project in `some-directory` and update the nam
## Workspaces

If your project is a cargo workspace the name will be taken from a `Shuttle.toml` in the root of the workspace, or
from the directory name of the workspace. See [workspaces](/getting-started/workspaces).
from the directory name of the workspace. See [Project structure](/configuration/project-structure).
61 changes: 61 additions & 0 deletions configuration/project-structure.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: Project structure
description: Cargo workspaces and custom binary names
---

This page describes what Shuttle expects from your project structure, how it handles cargo workspaces, and how to use a custom binary name.

## Basic structure

After initializing a basic Shuttle project, the file structure will look like this:

```
.
├── .gitignore
├── Cargo.toml
├── Shuttle.toml (optional)
└── src/
└── main.rs
```

The file `Shuttle.toml` is optional and can be used to override default settings for [project name](/configuration/project-name) and [deployment files](/configuration/files).

## Workspaces

Shuttle supports [cargo workspaces](https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html). Simply run
the project and deployment commands in the root of the workspace, and the project name will be taken from the
directory name of the workspace or a `Shuttle.toml` with a name key in the root of the workspace.
See [Project Name](/configuration/project-name) for more info.

This is an example of a workspace structure with shared code between a backend and frontend crate:

```
.
├── .gitignore
├── Cargo.toml
├── Shuttle.toml (optional)
├── backend
│ ├── Cargo.toml
│ └── src
│ └── main.rs (contains #[shuttle_runtime::main])
├── frontend
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── shared
├── Cargo.toml
└── src
└── lib.rs
```

### Caveats

We currently only support one Shuttle service per workspace, so you can have many crates in a workspace, but only
one crate with a `shuttle_runtime::main` macro.
We intend to allow starting several Shuttle services at the same time, as part of the same project.
The long term plan is to have one central service that routes to the other services in the project, sharing resources amongst them.
Any feedback on what you would like to see in this area is most welcome.

## Multiple binaries

If you want to keep your project structured for allowing both running with and without Shuttle, check out the [standalone-binary](https://github.com/shuttle-hq/shuttle-examples/tree/main/other/standalone-binary) example. This is great for gradually adding Shuttle into your project.
17 changes: 0 additions & 17 deletions getting-started/workspaces.mdx

This file was deleted.

44 changes: 31 additions & 13 deletions introduction/welcome.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
---
title: "Welcome"
description: "Shuttle is a Rust-native cloud development platform that lets you deploy your Rust apps for free."
size: "wide"
---

<CardGroup>
<Card title="Get Started" icon="circle-play" href="/getting-started/quick-start">
The quickstart guide to set up Shuttle
<Card
title="Get Started"
icon="circle-play"
color="#3d3"
href="/getting-started/installation"
>
Installation and quickstart guide
</Card>
<Card
title="What is Shuttle?"
icon="info"
href="/introduction/what-is-shuttle"
color="#33f"
>
Learn more about how Shuttle can help you deploy your app
Learn more about how Shuttle can help you deploy your Rust app
</Card>
<Card
title="Create & deploy a serverless calendar app"
icon="calendar"
href="/tutorials/serverless-calendar-app"
title="Examples"
icon="book"
href="/examples/axum"
color="#f8d5F2"
>
Learn how to deploy an example Calendar App with Shuttle
Get started from one of many templates
</Card>
<Card title="Get Involved" icon="hand" href="/community/get-involved">
If you are wondering what the best way is to get involved, here's how
<Card
title="Migration"
icon="Rocket"
href="/migration/migrating-to-shuttle"
>
Migrate an existing project to Shuttle
</Card>
</CardGroup>

Expand All @@ -33,25 +43,33 @@ size: "wide"
<Card
title="Give us a star on GitHub"
icon="star"
color="#fbdf24"
href="https://github.com/shuttle-hq/shuttle"
color="#fbbf24"
>
Check us out at shuttle-hq/shuttle
</Card>
<Card
title="Join our Discord server"
icon="discord"
href="https://discord.com/invite/shuttle"
color="#5865F2"
href="https://discord.com/invite/shuttle"
>
Click to accept invite
</Card>
<Card
title="Follow us on Twitter"
icon="twitter"
href="https://twitter.com/shuttle_dev"
color="#1DA1F2"
href="https://twitter.com/shuttle_dev"
>
Go to @shuttle_dev on Twitter
</Card>
<Card
title="Get Involved"
icon="hand"
color="#525"
href="/community/get-involved"
>
If you are wondering what the best way is to get involved, here's how
</Card>
</CardGroup>
2 changes: 1 addition & 1 deletion introduction/what-is-shuttle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ As a platform designed with a focus on providing an exceptional developer experi

```rust
#[shuttle_runtime::main]
async fn rocket(
async fn main(
// automatic db provisioning + hands you back an authenticated connection pool
#[shuttle_shared_db::Postgres] pool: PgPool,
) -> ShuttleRocket<...> {
Expand Down
4 changes: 2 additions & 2 deletions mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
"getting-started/quick-start",
"getting-started/local-run",
"getting-started/shuttle-commands",
"getting-started/idle-projects",
"getting-started/workspaces"
"getting-started/idle-projects"
]
},
{
"group": "Configuration",
"pages": [
"configuration/project-structure",
"configuration/project-name",
"configuration/files",
"configuration/environment",
Expand Down

0 comments on commit e247a95

Please sign in to comment.