Shuttle builds run on AWS CodeBuild, where we compile your Rust app and place it in a Shuttle runtime Debian-based Docker image.

Builder image

The Rust builder image is based on cargo-chef to utilize Docker-layer caching of the build dependencies.

Rust toolchain

The Rust version in the image is regularly updated to the latest stable stable-x86_64-unknown-linux-gnu toolchain.

By default, the wasm32-unknown-unknown target is installed, which enables compiling WASM frontends.

External tools

Apart from what is already found in the Debian-based cargo-chef image [1] [2], these apt packages are also installed:

  • clang
  • cmake
  • llvm-dev
  • libclang-dev
  • mold
  • protobuf-compiler

Additionally, these tools are installed:

  • cargo-binstall (latest)
  • trunk (0.19.2)
Some other build tool you think we should add? Let us know!

Customize build process

Feature flags

Use the β€œshuttle” feature flag for custom behavior when building on Shuttle.

Environment variables

The SHUTTLE=true env var is set in the builder image.

If you have build flags or env variables that need to be set during compilation, you can add them in .cargo/config.toml (docs) and include it in your deployment. Below are some examples.

.cargo/config.toml
[build]
rustflags = ["--foo", "bar"]

[env]
MY_ENV_VAR = "Shuttle to the moon! πŸš€πŸš€πŸš€"

Runtime image

The runtime image that your built executable is placed in is a bookworm-slim (Debian 12) with ca-certificates and curl installed.

(EXPERIMENTAL) Hook scripts

This feature is experimental and can change

There are three optional bash scripts that can be used to run custom commands during the build. Create them at the root of your project.

  • shuttle_prebuild.sh: Runs before cargo build. Can be used to install custom build dependencies.
  • shuttle_postbuild.sh: Runs after cargo build.
  • shuttle_setup_container.sh: Runs in the runtime image before build artifacts are copied into it. Can be used to install custom runtime dependencies.

Example: Install a custom Rust toolchain

In this example, we install and switch to the nighlty toolchain.

shuttle_prebuild.sh
rustup install nightly --profile minimal
rustup default nightly

Example: Install a build dependency

shuttle_prebuild.sh
apt update
apt install -y libopus-dev

Example: Build a WASM frontend

shuttle_postbuild.sh
cd frontend
trunk build --release

Note: To use the built static assets at runtime, use build.assets.

Example: Install a runtime dependency

shuttle_setup_container.sh
apt update
apt install -y ffmpeg