# Rust Buildpack on App Platform App Platform is a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images. It automatically builds, deploys, and scales components while handling all underlying infrastructure. ## How App Platform Builds Images App Platform supports two ways to build an image for your app: [Cloud Native Buildpacks](https://buildpacks.io/) and [Dockerfiles](https://docs.docker.com/engine/reference/builder/). When you give App Platform access to your code, it defaults to using a Dockerfile if one is present in the root of the directory or specified in the app spec. Otherwise, App Platform checks your code to determine what language or framework it uses. If it supports the language or framework, it chooses an appropriate resource type and uses the proper buildpack to build the app and deploy a container. App Platform uses the [Paketo Community’s Rust buildpack](https://github.com/paketo-community/rust) to detect and build Rust-based apps. ## Rust Buildpack Overview The Paketo Community Rust buildpack is a meta buildpack that bundles the Rust-related CNBs in the correct order. It includes: - [paketo-community/rustup](https://github.com/paketo-community/rustup) - [paketo-community/rust-dist](https://github.com/paketo-community/rust-dist) - [paketo-community/cargo](https://github.com/paketo-community/cargo) ## Individual Buildpacks ### paketo-community/rustup The Rustup buildpack installs and runs `rustup` to provision the Rust toolchain when another buildpack requires `rust` and `BP_RUSTUP_ENABLED=true` (default). #### Detection and Behavior - Participates when another buildpack requires `rust` and rustup is enabled. - Installs `rustup-init`, then installs the Rust toolchain. - Honors `rust-toolchain` or `rust-toolchain.toml` when present. - Adds a Rust target via `rustup target add` when `BP_RUST_TARGET` is set. #### Configuration - `BP_RUSTUP_ENABLED` (default `true`): Enable rustup installation. - `BP_RUST_TOOLCHAIN` (default `stable`): Toolchain to install (`stable`, `beta`, `nightly`, or a version). - `BP_RUST_PROFILE` (default `minimum`): Profile to install (`minimum`, `default`, `complete`). - `BP_RUST_TARGET`: Additional Rust target to install. - `BP_RUSTUP_INIT_VERSION`: Version of `rustup-init` (default latest `1.*`). - `BP_RUSTUP_INIT_LIBC` (default `gnu`): libc implementation (`gnu` or `musl`). ### paketo-community/rust-dist The Rust Dist buildpack installs a Rust toolchain from a packaged distribution. It always passes detection and participates when `rust` is required by another buildpack. #### Detection and Behavior - Always passes detection. - Contributes Rust to a build or cache layer and adds the toolchain to `$PATH` when requested. #### Configuration - `BP_RUST_VERSION`: Rust version to install. The buildpack supports Rust major version 1, including any 1.x.x versions. #### Bindings - Optional `dependency-mapping` binding to map dependency digests to custom URIs. ### paketo-community/cargo The Cargo buildpack builds Rust applications using Cargo and expects Rust and Cargo to be available from rustup or rust-dist. #### Detection and Behavior - Participates when both `Cargo.toml` and `Cargo.lock` exist in the app root. - Requests Rust and Cargo. - Caches build artifacts by linking `target/` to a cache layer. - Builds workspace members with `cargo install` and registers process types for binary targets. - Removes source files from `/workspace` and leaves only built binaries. - Installs and uses `tini` by default for PID1 signal handling. #### Configuration - `BP_CARGO_INSTALL_ARGS` (default `--locked`): Additional args for `cargo install` (buildpack controls `--path`, `--root`, and `--color`). - `BP_CARGO_WORKSPACE_MEMBERS`: Comma-separated workspace package names to build. - `BP_CARGO_INSTALL_TOOLS`: Space-separated list of tools to install with `cargo install` during build. - `BP_CARGO_INSTALL_TOOLS_ARGS`: Args applied when installing tools. - `BP_CARGO_TINI_DISABLED` (default `false`): Disable installing/using `tini`. - `BP_STATIC_BINARY_TYPE`: Static binary type for tiny/static stacks (`muslc` or `gnulibc`). - `BP_INCLUDE_FILES`: Colon-separated include globs for source files to keep. - `BP_EXCLUDE_FILES`: Colon-separated exclude globs for source files to remove. - `BP_DISABLE_SBOM` (default `false`): Disable the SBOM scan. ## Build Behavior If `BP_RUST_VERSION` is not set, the buildpack installs and uses the latest Rust 1.x version. By default, the Rust buildpack registers process types for all binary projects in your workspace. If you add a `Procfile`, the buildpack uses its web process as the startup command. ## Tini Process Manager The buildpack installs `tini` by default to handle PID1 responsibilities and signal forwarding. If you need to disable it, set the environment variable `BP_CARGO_TINI_DISABLED=true` at build time.