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(rust): follow depot recommendations for dockerfiles #29294

Merged
merged 5 commits into from
Feb 28, 2025

Conversation

oliverb123
Copy link
Contributor

As per: https://depot.dev/docs/container-builds/how-to-guides/optimal-dockerfiles/rust-dockerfile

First build will be slower since the sccache layer will have to build form scratch, but hopefully from there we'll be quicker

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR optimizes Rust Dockerfiles by implementing Depot's recommended build caching strategies for improved performance.

  • Added sccache as a Rust compiler wrapper with RUSTC_WRAPPER=sccache SCCACHE_DIR=/sccache environment variables
  • Implemented Docker build cache mounts with --mount=type=cache for cargo registry, git, and sccache directories
  • Switched from lukemathwalker/cargo-chef to rust:1.82 base image with manually installed cargo-chef
  • Added --bin $BIN flag to cargo chef commands for more targeted builds
  • Maintained the same multi-stage build pattern (planner → builder → runtime) for both main Rust and feature-flags Dockerfiles

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@oliverb123 oliverb123 enabled auto-merge (squash) February 28, 2025 11:20
@oliverb123 oliverb123 merged commit 286ba85 into master Feb 28, 2025
88 checks passed
@oliverb123 oliverb123 deleted the olly_rust_dockerfile_sccache branch February 28, 2025 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants