--- title: "Rust" description: "Deploy Rust applications on Miget with optimized dependency caching and release binaries." --- Miget Buildpacks automatically detect and build your Rust applications when you select **Auto detection (Miget Buildpacks)** as the build method. No configuration is required for most projects. For the full reference, visit the [migetpacks Rust documentation](https://migetpacks.com/languages/rust). ## Detection Your application is detected as Rust when one of these files is present in the root directory: - `Cargo.toml` - `Cargo.lock` ## Version Detection The Rust toolchain version is determined from the following sources, in order of priority: 1. `rust-toolchain` file 2. `rust-toolchain.toml` file 3. `rust-version` field in `Cargo.toml` If no version is specified, the latest stable version is used. ## Build Process During the build, the following steps are performed: 1. **Rust toolchain installation** - The appropriate version of the Rust toolchain is installed. 2. **Dependency caching** - A dummy source technique is used to cache dependency compilation separately from your application code, which significantly speeds up subsequent builds. 3. **Release build** - Your application is compiled as a release binary using `cargo build --release`. 4. **Workspace support** - Cargo workspaces are fully supported. The buildpack detects and builds workspace members correctly. 5. **Static assets** - If `static/` or `public/` directories are present, they are copied to the final image. ## Run Command The binary name is auto-detected from your `Cargo.toml`. The compiled release binary is used as the run command. You can override the run command by defining a `web` process in a `Procfile` at the root of your repository. You can also override the run command directly in the Miget dashboard when creating your app or changing the deployment source. Builder settings showing Run Command override ## Configuration You can customize the build and runtime behavior through the Miget dashboard and repository configuration files: - **Environment variables** - Set under **Settings -> Variables** in the Miget dashboard - **Procfile** - Define the start command at the root of your repository - **Project Path** - For monorepo setups, specify the subdirectory containing your application code in the **Advanced** tab - **Pre-Deploy Command** - Run a command before deployment (e.g., database migrations) in the **Advanced** tab - **Post-Deploy Command** - Run a command after successful deployment (e.g., seeding data, cache warming) in the **Advanced** tab ## Docker Hardened Images You can enable Docker Hardened Images (DHI) in the **Advanced** tab when creating your app or changing the deployment source. When enabled, your application is built using distroless runtime images with a minimal attack surface, no shell, and no package manager. Advanced builder settings with Docker Hardened Images toggle For the complete reference, see the [migetpacks Rust documentation](https://migetpacks.com/languages/rust).