Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: v0.42.0 #271

Merged
merged 7 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuration/shuttle-versions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Combining all of the above, these are the recommended steps for upgrading a Shut

2. Update your project's `shuttle-...` dependencies in `Cargo.toml`:
```toml Cargo.toml
shuttle-runtime = "0.41.0"
shuttle-runtime = "0.42.0"
# etc
```

Expand Down
6 changes: 3 additions & 3 deletions examples/actix-postgres.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ edition = "2021"

[dependencies]
actix-web = "4.3.1"
shuttle-actix-web = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-actix-web = "0.42.0"
shuttle-runtime = "0.42.0"
serde = "1.0.148"
shuttle-shared-db = { version = "0.41.0", features = ["postgres", "sqlx"] }
shuttle-shared-db = { version = "0.42.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/actix-websocket-actorless.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ futures = "0.3"
reqwest = "0.11"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
shuttle-actix-web = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-actix-web = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = { version = "1", features = ["rt-multi-thread", "sync"] }
tracing = "0.1"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/actix.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ edition = "2021"

[dependencies]
actix-web = "4.3.1"
shuttle-actix-web = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-actix-web = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.26.0"
```
</CodeGroup>
Expand Down
4 changes: 2 additions & 2 deletions examples/axum-jwt-authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ jsonwebtoken = "8.3.0"
once_cell = "1.18.0"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
shuttle-axum = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-axum = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.28.2"
tracing-subscriber = "0.3.17"
```
Expand Down
6 changes: 3 additions & 3 deletions examples/axum-postgres.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ edition = "2021"
[dependencies]
axum = "0.7.3"
serde = { version = "1.0.188", features = ["derive"] }
shuttle-axum = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-shared-db = { version = "0.41.0", features = ["postgres", "sqlx"] }
shuttle-axum = "0.42.0"
shuttle-runtime = "0.42.0"
shuttle-shared-db = { version = "0.42.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.28.2"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/axum-static-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ publish = false

[dependencies]
axum = "0.7.3"
shuttle-axum = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-axum = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.28.2"
tower-http = { version = "0.5.0", features = ["fs"] }
```
Expand Down
4 changes: 2 additions & 2 deletions examples/axum-websockets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ futures = "0.3.28"
reqwest = "0.11.23"
serde = { version = "1.0.163", features = ["derive"] }
serde_json = "1.0.96"
shuttle-axum = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-axum = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.28.2"
tower-http = { version = "0.5.0", features = ["fs"] }
```
Expand Down
4 changes: 2 additions & 2 deletions examples/axum.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ edition = "2021"

[dependencies]
axum = "0.7.3"
shuttle-axum = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-axum = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.28.2"
```
</CodeGroup>
Expand Down
9 changes: 4 additions & 5 deletions examples/poise.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This example shows how to build a Poise bot with Shuttle that responds to the `/
```rust src/main.rs
use anyhow::Context as _;
use poise::serenity_prelude::{ClientBuilder, GatewayIntents};
use shuttle_secrets::SecretStore;
use shuttle_runtime::SecretStore;
use shuttle_serenity::ShuttleSerenity;

struct Data {} // User data, which is stored and accessible in all command invocations
Expand All @@ -30,7 +30,7 @@ async fn hello(ctx: Context<'_>) -> Result<(), Error> {
}

#[shuttle_runtime::main]
async fn main(#[shuttle_secrets::Secrets] secret_store: SecretStore) -> ShuttleSerenity {
async fn main(#[shuttle_runtime::Secrets] secret_store: SecretStore) -> ShuttleSerenity {
// Get the discord token set in `Secrets.toml`
let discord_token = secret_store
.get("DISCORD_TOKEN")
Expand Down Expand Up @@ -72,10 +72,9 @@ publish = false
[dependencies]
anyhow = "1.0.68"
poise = "0.6.1"
shuttle-runtime = "0.41.0"
shuttle-secrets = "0.41.0"
shuttle-runtime = "0.42.0"
# Since poise is a serenity command framework, it can run on Shuttle with shuttle-serenity
shuttle-serenity = "0.41.0"
shuttle-serenity = "0.42.0"
tracing = "0.1.37"
tokio = "1.26.0"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/rocket-jwt-authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ jsonwebtoken = { version = "8.1.1", default-features = false }
lazy_static = "1.4.0"
rocket = { version = "0.5.0", features = ["json"] }
serde = { version = "1.0.148", features = ["derive"] }
shuttle-rocket = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-rocket = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.26.0"
```
Your `main.rs` should look like this:
Expand Down
6 changes: 3 additions & 3 deletions examples/rocket-postgres.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ edition = "2021"
[dependencies]
rocket = { version = "0.5.0", features = ["json"] }
serde = "1.0.148"
shuttle-rocket = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-shared-db = { version = "0.41.0", features = ["postgres", "sqlx"] }
shuttle-rocket = "0.42.0"
shuttle-runtime = "0.42.0"
shuttle-shared-db = { version = "0.42.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
```
Expand Down
4 changes: 2 additions & 2 deletions examples/rocket-static-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ publish = false

[dependencies]
rocket = "0.5.0"
shuttle-rocket = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-rocket = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.26.0"
```

Expand Down
4 changes: 2 additions & 2 deletions examples/rocket.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ edition = "2021"

[dependencies]
rocket = "0.5.0"
shuttle-rocket = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-rocket = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.26.0"
```
</CodeGroup>
Expand Down
11 changes: 5 additions & 6 deletions examples/serenity-todo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use serenity::model::application::{CommandDataOptionValue, CommandOptionType, In
use serenity::model::gateway::Ready;
use serenity::model::id::GuildId;
use serenity::prelude::*;
use shuttle_secrets::SecretStore;
use shuttle_runtime::SecretStore;
use sqlx::{Executor, PgPool};
use tracing::{error, info};

Expand Down Expand Up @@ -158,7 +158,7 @@ impl EventHandler for Bot {
#[shuttle_runtime::main]
async fn serenity(
#[shuttle_shared_db::Postgres] pool: PgPool,
#[shuttle_secrets::Secrets] secret_store: SecretStore,
#[shuttle_runtime::Secrets] secret_store: SecretStore,
) -> shuttle_serenity::ShuttleSerenity {
// Get the discord token set in `Secrets.toml`
let token = secret_store
Expand Down Expand Up @@ -269,10 +269,9 @@ edition = "2021"
anyhow = "1.0.66"
serde = "1.0.148"
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
shuttle-runtime = "0.41.0"
shuttle-secrets = "0.41.0"
shuttle-serenity = "0.41.0"
shuttle-shared-db = { version = "0.41.0", features = ["postgres", "sqlx"] }
shuttle-runtime = "0.42.0"
shuttle-serenity = "0.42.0"
shuttle-shared-db = { version = "0.42.0", features = ["postgres", "sqlx"] }
sqlx = "0.7.1"
tokio = "1.26.0"
tracing = "0.1.37"
Expand Down
17 changes: 6 additions & 11 deletions examples/serenity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ This example shows how to build a Serenity bot with Shuttle that responds to the

<CodeGroup>
```rust src/main.rs
use anyhow::anyhow;
use anyhow::Context as _;
use serenity::async_trait;
use serenity::model::channel::Message;
use serenity::model::gateway::Ready;
use serenity::prelude::*;
use shuttle_secrets::SecretStore;
use shuttle_runtime::SecretStore;
use tracing::{error, info};

struct Bot;
Expand All @@ -57,14 +57,10 @@ impl EventHandler for Bot {

#[shuttle_runtime::main]
async fn serenity(
#[shuttle_secrets::Secrets] secret_store: SecretStore,
#[shuttle_runtime::Secrets] secrets: SecretStore,
) -> shuttle_serenity::ShuttleSerenity {
// Get the discord token set in `Secrets.toml`
let token = if let Some(token) = secret_store.get("DISCORD_TOKEN") {
token
} else {
return Err(anyhow!("'DISCORD_TOKEN' was not found").into());
};
let token = secrets.get("DISCORD_TOKEN").context("'DISCORD_TOKEN' was not found")?;

// Set gateway intents, which decides what events the bot will be notified about
let intents = GatewayIntents::GUILD_MESSAGES | GatewayIntents::MESSAGE_CONTENT;
Expand All @@ -91,9 +87,8 @@ edition = "2021"
[dependencies]
anyhow = "1.0.66"
serenity = { version = "0.12.0", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
shuttle-runtime = "0.41.0"
shuttle-secrets = "0.41.0"
shuttle-serenity = "0.41.0"
shuttle-runtime = "0.42.0"
shuttle-serenity = "0.42.0"
tokio = "1.26.0"
tracing = "0.1.37"
```
Expand Down
38 changes: 38 additions & 0 deletions getting-started/local-run.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,41 @@ if cfg!(debug_assertions) {
router = router.layer(tower_livereload::LiveReloadLayer::new());
}
```

### Docker engines

`cargo-shuttle` uses the [bollard](https://crates.io/crates/bollard) crate to interact with the Docker engine on local runs.

If you are using a non-standard Docker engine, you might get this error:

```text
got unexpected error while inspecting docker container:
error trying to connect: No such file or directory
```

The error is emitted due to bollard not connecting to the correct Docker Socket location.

On Unix, bollard defaults to connecting to `unix:///var/run/docker.sock` unless the `DOCKER_HOST` env variable overrides it.

If you end up using a `DOCKER_HOST` like below, you can add the `export DOCKER_HOST=...` line to your shell's config file to have it automatically set in new shell sessions.

#### Docker Desktop

```bash
export DOCKER_HOST="unix://$HOME/.docker/run/docker.sock"
```

#### Podman

You will need to expose a rootless socket for Podman, and then set the `DOCKER_HOST` environment variable:

```bash
podman system service --time=0 unix:///tmp/podman.sock
export DOCKER_HOST=unix:///tmp/podman.sock
```

#### Colima

```bash
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
```
1 change: 1 addition & 0 deletions getting-started/shuttle-commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ All project-related commands can use:
- `cargo shuttle logs --latest`: Get all logs from the currently running deployment.
- `cargo shuttle logs <id>`: Get all logs from a specific deployment.
- `cargo shuttle logs --follow`: Stream logs of the deployed service and stream them to your terminal.
- `cargo shuttle logs --raw`: Print the logs without timestamps and origin tags. The `--raw` flag is also available for the `run` and `deploy` commands.

### Manage resources

Expand Down
8 changes: 2 additions & 6 deletions introduction/how-shuttle-works.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,10 @@ Here are the examples on how to use them, once you add the required annotations
```rust
#[shuttle_runtime::main]
async fn axum(
#[shuttle_secrets::Secrets] secret_store: SecretStore,
#[shuttle_runtime::Secrets] secrets: SecretStore,
) -> shuttle_axum::ShuttleAxum {
// Get secret defined in `Secrets.toml` file.
let secret = if let Some(secret) = secret_store.get("MY_API_KEY") {
secret
} else {
return Err(anyhow!("secret was not found").into());
};
let secret = secrets.get("MY_API_KEY").expect("secret was not found");
}
```

Expand Down
14 changes: 4 additions & 10 deletions migration/migrating-to-shuttle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ The first step is to add `shuttle-runtime` and `shuttle-axum` to your dependenci
cargo add shuttle-runtime shuttle-axum
```

Any [secrets](/resources/shuttle-secrets) you need to use will be kept in a `Secrets.toml` file (dev secrets to be held in `Secrets.dev.toml`) which will be placed at the `Cargo.toml` level - you'll want to use the `shuttle-secrets` crate to be able to use the new secrets:

```bash
cargo add shuttle-secrets
```

Your secrets file will look the same as your previous .env file, so you won't need to change anything.
Any [secrets](/resources/shuttle-secrets) you need to use will be kept in a `Secrets.toml` file (dev secrets in `Secrets.dev.toml`) which will be placed at the `Cargo.toml` level.

You can also easily get a provisioned database like so (this example will be for a provisioned PostgreSQL instance specifically):

Expand All @@ -33,14 +27,14 @@ cargo add shuttle-shared-db --features postgres
```

If you have any database records you'd like to keep, it would be a good idea to export them so that they can be migrated to the new database.
**You will not need a secrets file if you only need a provisioned Postgres database - this will be automatically be provisioned to you in the form of a SQLx connection.**
**You will not need a secrets file if you only need a provisioned Postgres database - this will be automatically be provisioned and given to you in the form of a connection string or an sqlx pool.**

## Migrating your Code

To be able to run your project on Shuttle, you need to make a few changes to your code.
Instead of the `tokio::main` macro, you will use the `shuttle_runtime::main` macro and swap out `dotenvy` for Shuttle's Postgres annotation:

This is what your `main.rs` file looks before:
This is what your `main.rs` file looks like before:

```rust main.rs
#[tokio::main]
Expand Down Expand Up @@ -72,7 +66,7 @@ And this is what it looks like after:
#[shuttle_runtime::main]
pub async fn axum (
#[shuttle_shared_db::Postgres] pool: PgPool,
#[shuttle_secrets::Secrets] secrets: shuttle_secrets::SecretStore,
#[shuttle_runtime::Secrets] secrets: shuttle_runtime::SecretStore,
) -> shuttle_axum::ShuttleAxum {
sqlx::migrate!()
.run(&pool)
Expand Down
6 changes: 3 additions & 3 deletions resources/custom-resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ edition = "2021"
async-trait = "0.1.56"
axum = "0.7.3"
serde = { version = "1.0.148", default-features = false, features = ["derive"] }
shuttle-service = "0.41.0"
shuttle-axum = "0.41.0"
shuttle-runtime = "0.41.0"
shuttle-service = "0.42.0"
shuttle-axum = "0.42.0"
shuttle-runtime = "0.42.0"
tokio = "1.28.2"
```
</CodeGroup>
2 changes: 1 addition & 1 deletion resources/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Overview"
icon: "face-monocle"
---

The next sections go over one by one the resources currently supported by Shuttle. In broad terms, for the resource needed, simply mark up your code with the appropriate annotation. This is very powerful and brings several benefits:
This section covers the resources currently supported by Shuttle. In broad terms, for the resource needed, simply mark up your code with the appropriate annotation. This is very powerful and brings several benefits:

- simplicity
- receive a database by writing a simple annotation
Expand Down
Loading
Loading