Skip to content

[BLD]: unify Rust Dockerfiles for faster builds #4479

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

Merged
merged 2 commits into from
May 8, 2025

Conversation

codetheweb
Copy link
Contributor

@codetheweb codetheweb commented May 7, 2025

Description of changes

This PR unifies the 5 separate Rust Dockerfiles into 1. This results in substantially faster builds as well as being cleaner and easier to maintain.

After this PR, the old Rust Dockerfiles are no longer used in this repo but I'm keeping them around until all downstream consumers are updated to use the new rust/Dockerfile.

Timings

I tested the difference in (local) speed with 3 scenarios. For each one, I measured the time from the start of the build to when all services in Tilt were green.

before after speedup
cold tilt up 7m14s 3m55s 1.8x
new comment in rust/types/src/api_types.rs 2m2s 58s 2.1x
new comment in rust/garbage_collector/src/lib.rs 37s 29s 1.3x

Copy link

github-actions bot commented May 7, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@codetheweb codetheweb marked this pull request as ready for review May 7, 2025 18:06
@codetheweb codetheweb requested a review from HammadB May 7, 2025 18:06
COPY idl/ idl/
COPY Cargo.toml Cargo.toml
COPY Cargo.lock Cargo.lock
COPY rust/ rust/
Copy link
Contributor

Choose a reason for hiding this comment

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

[BestPractice]

Consider adding a .dockerignore file to speed up the build process and reduce context size. This is especially important since your Dockerfile copies the entire rust/ directory. A properly configured .dockerignore file would exclude unnecessary files like development artifacts, tests, and documentation from the build context.


ENV EXCLUDED_PACKAGES="chromadb_rust_bindings chromadb-js-bindings chroma-benchmark "

RUN --mount=type=cache,sharing=locked,target=/chroma/target/ \
Copy link
Contributor

Choose a reason for hiding this comment

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

[Documentation]

The builder stage uses --mount=type=cache for caching but this requires BuildKit to be enabled. Consider adding a comment to document this requirement or a fallback mechanism for environments where BuildKit might not be available.

Copy link
Contributor

propel-code-bot bot commented May 7, 2025

Unify Rust Dockerfiles for Faster Builds

This PR consolidates 5 separate Rust Dockerfiles into a single unified Dockerfile with multiple targets. The change significantly improves build times (1.3x-2.1x speedup) by leveraging shared build stages and better caching. It also updates Tiltfile and GitHub workflows to use the new Dockerfile.

Key Changes:
• Created a single unified rust/Dockerfile with multiple targets that replaces 5 separate Dockerfiles
• Updated Tiltfile to reference the new Dockerfile with appropriate targets
• Modified CI workflows to use the new Docker build pattern
• Implemented Docker login for higher pull rate limits

Affected Areas:
• Docker build infrastructure
• CI/CD workflows
• Local development environment

This summary was automatically generated by @propel-code-bot

--mount=type=cache,sharing=locked,target=/usr/local/cargo/registry/ \
if [ "$RELEASE_MODE" = "1" ]; then cargo build --workspace $(printf -- '--exclude %s ' $EXCLUDED_PACKAGES) --release; else cargo build --workspace $(printf -- '--exclude %s ' $EXCLUDED_PACKAGES); fi && \
# Move CLI binary
if [ "$RELEASE_MODE" = "1" ]; then mv target/release/chroma ./chroma; else mv target/debug/chroma ./chroma; fi && \
Copy link
Collaborator

Choose a reason for hiding this comment

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

i wish there was a way to reduce the copy paste here.

@codetheweb codetheweb force-pushed the bld-single-rust-dockerfile branch from 42c4572 to eea1f2e Compare May 8, 2025 20:29
@codetheweb codetheweb enabled auto-merge (squash) May 8, 2025 20:29
@codetheweb codetheweb disabled auto-merge May 8, 2025 20:40
@codetheweb codetheweb force-pushed the bld-single-rust-dockerfile branch from 73e4e5f to 8797f99 Compare May 8, 2025 21:30
@codetheweb codetheweb force-pushed the bld-single-rust-dockerfile branch from 8797f99 to 1395041 Compare May 8, 2025 21:48
@codetheweb codetheweb merged commit 3f2d8b1 into main May 8, 2025
70 checks passed
@codetheweb codetheweb deleted the bld-single-rust-dockerfile branch May 8, 2025 23:05
codetheweb added a commit that referenced this pull request May 9, 2025
## Description of changes

#4479 added auth against
DockerHub for higher rate limits when pulling, but I forgot to update
the release workflow to properly propogate the secrets down.
codetheweb added a commit that referenced this pull request May 14, 2025
itaismith pushed a commit that referenced this pull request May 23, 2025
## Description of changes

#4479 added auth against
DockerHub for higher rate limits when pulling, but I forgot to update
the release workflow to properly propogate the secrets down.
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