-
Notifications
You must be signed in to change notification settings - Fork 39
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
build: adjust docker build context #2336
Conversation
WalkthroughThe changes in this pull request involve modifications to the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
Dockerfile (1)
393-394
: Remove commented-out code or explain its necessityThe commented-out
RUN
command at line 394 can cause confusion. If it's no longer needed, consider removing it. If it's temporarily disabled, add a comment explaining why.Apply this diff to remove the commented-out code:
-#RUN touch /platform/packages/dapi-grpc/build.rs
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
.dockerignore
(1 hunks)Dockerfile
(11 hunks)
✅ Files skipped from review due to trivial changes (1)
- .dockerignore
🔇 Additional comments (6)
Dockerfile (6)
1-1
: Dockerfile syntax version update is acceptable
Updating to # syntax = docker/dockerfile:1.7-labs
enables new features and optimizations available in Dockerfile syntax version 1.7.
288-288
: Verify that COPY --parents
is supported in your build environment
The --parents
flag in the COPY
command is an experimental feature introduced in BuildKit with Dockerfile syntax version 1.7-labs
. Ensure that your Docker builder supports this feature to prevent build failures.
360-360
: Verify that COPY --parents
is supported in your build environment
As noted earlier, the use of COPY --parents
is an experimental feature. Please ensure your build environment supports it.
447-447
: Verify that COPY --parents
is supported in your build environment
Reiterating the earlier point, ensure that the COPY --parents
feature is supported to avoid issues during the build.
493-495
: Ensure wildcard deletion of packages/rs-*
is safe
Using rm -rf packages/rs-*
deletes all directories matching rs-*
. Verify that this won't remove necessary packages, especially if new packages matching this pattern are added in the future.
385-386
: 🛠️ Refactor suggestion
Remove unnecessary packages from the build context
The TODO comment indicates that packages/rs-drive-proof-verifier
may not be needed here as well. Removing it can improve the build efficiency.
Apply this diff:
packages/rs-json-schema-compatibility-validator \
- # TODO: We don't need those. Maybe dynamically remove them from workspace or move outside of monorepo?
- packages/rs-drive-proof-verifier \
packages/wasm-dpp \
# TODO: We don't need those. Maybe dynamically remove them from workspace or move outside of monorepo? | ||
packages/rs-drive-proof-verifier \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Remove unnecessary packages from the build context
The TODO comment indicates that packages/rs-drive-proof-verifier
may not be needed. Removing it from the COPY
command can optimize the build context and reduce build times.
Apply this diff to remove the unnecessary package:
packages/rs-json-schema-compatibility-validator \
- # TODO: We don't need those. Maybe dynamically remove them from workspace or move outside of monorepo?
- packages/rs-drive-proof-verifier \
packages/wasm-dpp \
Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (5)
Dockerfile (5)
288-320
: Optimize build context by excluding unnecessary filesThe
COPY
command includes several packages that might not be needed for the build planner stage. Consider using a.dockerignore
file to exclude test files, documentation, and other non-essential files to reduce the build context size.#!/bin/bash # Check the size of copied directories find packages -type f -name "*.md" -o -name "*.test.*" -o -name "*.spec.*" | wc -l
393-394
: Remove commented-out codeThe commented-out workaround for dapi-grpc's build.rs should be either implemented or removed to maintain clean code.
-# Workaround: as we cache dapi-grpc, its build.rs is not rerun, so we need to touch it -#RUN touch /platform/packages/dapi-grpc/build.rs
417-420
: Optimize layer size reductionGood practice of removing the /platform directory to reduce layer size. However, consider combining this with the previous commands in the same RUN instruction to avoid creating an intermediate layer.
- cp target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \ - if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \ - # Remove /platform to reduce layer size - rm -rf /platform + cp target/${OUT_DIRECTORY}/drive-abci /artifacts/ && \ + if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \ + cd / && rm -rf /platform
493-495
: Optimize cleanup processThe cleanup process removes Rust packages after the build. Consider moving this cleanup into the same RUN instruction as the build to reduce layer size.
- if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \ - # Remove target directory and rust packages to save space - rm -rf target packages/rs-* + if [[ -x /usr/bin/sccache ]]; then sccache --show-stats; fi && \ + rm -rf target packages/rs-* && \ + yarn cache clean
552-554
: Consider using multi-stage build for dashmateThe dashmate package copy could be optimized by using a separate build stage for its dependencies, similar to how the JS build stage is structured.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
Dockerfile
(11 hunks)
🔇 Additional comments (2)
Dockerfile (2)
629-630
: LGTM: Clean DAPI package copy
The DAPI package copy is well-structured and follows the pattern established in other stages.
1-1
: Consider the implications of using labs features
The Dockerfile syntax is set to docker/dockerfile:1.7-labs
, which includes experimental features. While this enables advanced functionality, be aware that labs features may change or be removed in future versions.
✅ Verification successful
Let me gather more specific information about the labs features usage in the Dockerfile.
Labs features are actively utilized and provide significant benefits
The Dockerfile makes effective use of labs features that improve build performance and maintainability:
- Cache mounts for Cargo registry and git database, which significantly speed up Rust builds
--parents
flag with COPY commands for maintaining directory structure- All features used are stable within the labs feature set
These features provide substantial benefits for the build process and their usage is justified. The warning about labs features can be dismissed as the benefits outweigh the risks in this case.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check if any labs-specific features are used in the Dockerfile
rg -l "^#syntax.*labs" .
Length of output: 1132
Script:
#!/bin/bash
# Check for labs-specific features in the Dockerfile
rg "^#syntax.*labs" Dockerfile
# Look for common labs features
rg -i "mount=?type=(secret|ssh|cache)" Dockerfile
rg "RUN.*--mount=" Dockerfile
rg "COPY.*--parents" Dockerfile
Length of output: 1814
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Issue being fixed or feature implemented
All docker Images are building when you modify any file in monorepo.
What was done?
How Has This Been Tested?
Changing various files and building locally
Breaking Changes
None
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
New Features
Chores
.dockerignore
to exclude the.github
directory from the Docker build context.