-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add docker-context option #250
Conversation
Warning Rate limit exceeded@dzirtusss has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 22 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (5)
WalkthroughThe pull request introduces a new option for specifying the Docker build context directory across multiple files. The changes enable users to provide a custom Docker context when building images, with modifications made to the Changes
Sequence DiagramsequenceDiagram
participant User
participant BuildImage
participant Controlplane
participant Docker
User->>BuildImage: Specify docker_context
BuildImage->>Controlplane: Call image_build with context
Controlplane->>Docker: Build image using specified context
Docker-->>Controlplane: Image build result
Poem
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: 0
🧹 Nitpick comments (2)
lib/command/base.rb (1)
446-455
: LGTM! Consider enhancing the option description.The option is well-structured and follows the established pattern. However, the description could be more informative.
Consider updating the description to be more specific:
- desc: "Path to the docker build context directory", + desc: "Path to the Docker build context directory (defaults to application directory)",lib/core/controlplane.rb (1)
93-101
: Security consideration: Validate docker_context path.While the implementation is functionally correct, the docker_context value is used directly in command construction without validation. This could potentially lead to command injection if the value contains shell metacharacters.
Consider adding path validation:
def image_build(image, dockerfile:, docker_context:, docker_args: [], build_args: []) + # Validate docker_context is a safe path + raise ArgumentError, "Invalid docker context path" unless File.directory?(docker_context) && !docker_context.match?(/[;&|]/) + # https://docs.controlplane.com/guides/push-image#step-2 # Might need to use `docker buildx build` if compatiblitity issues arise cmd = "docker build --platform=linux/amd64 -t #{image} -f #{dockerfile}"
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
lib/command/base.rb
(1 hunks)lib/command/build_image.rb
(2 hunks)lib/core/controlplane.rb
(1 hunks)
🔇 Additional comments (2)
lib/command/build_image.rb (2)
8-9
: LGTM! Option correctly added to OPTIONS array.
The docker_context_option is properly integrated into the command options.
38-43
: LGTM! Docker context handling is implemented correctly.
The implementation:
- Properly defaults to app_dir if no context is specified
- Correctly passes the context to the image_build method
3927273
to
34010aa
Compare
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: 0
🧹 Nitpick comments (1)
CHANGELOG.md (1)
25-25
: Consider adding more context to the changelog entry.The entry could be more informative by briefly explaining the purpose of the
--docker-context
option.-Added `--docker-context` option to `build-image` command. [PR 250](https://github.com/shakacode/control-plane-flow/pull/250) by [Sergey Tarasov](https://github.com/dzirtusss). +Added `--docker-context` option to `build-image` command to specify custom Docker build context directory. [PR 250](https://github.com/shakacode/control-plane-flow/pull/250) by [Sergey Tarasov](https://github.com/dzirtusss).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
CHANGELOG.md
(1 hunks)lib/command/base.rb
(1 hunks)lib/command/build_image.rb
(2 hunks)lib/core/controlplane.rb
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- lib/command/base.rb
- lib/command/build_image.rb
- lib/core/controlplane.rb
🔇 Additional comments (2)
CHANGELOG.md (2)
23-26
: LGTM! Entry follows the changelog format.
The new entry is correctly placed under the "Added" section and follows the established format with proper PR link and author attribution.
Line range hint 1-24
: LGTM! Documentation follows best practices.
The changelog maintains high quality by following Keep a Changelog recommendations, maintaining clear version history, and including proper linking.
🧰 Tools
🪛 LanguageTool
[uncategorized] ~19-~19: Use a comma before ‘but’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...mmand fails when runner workload has ENV but original workload does not. [PR 227](ht...
(COMMA_COMPOUND_SENTENCE_2)
34010aa
to
33ed951
Compare
@@ -1,5 +1,7 @@ | |||
# frozen_string_literal: true | |||
|
|||
require "resolv" |
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.
why this added?
# https://docs.controlplane.com/guides/push-image#step-2 | ||
# Might need to use `docker buildx build` if compatiblitity issues arise | ||
cmd = "docker build --platform=linux/amd64 -t #{image} -f #{dockerfile}" | ||
cmd += " --progress=plain" if ControlplaneApiDirect.trace | ||
|
||
cmd += " #{docker_args.join(' ')}" if docker_args.any? | ||
build_args.each { |build_arg| cmd += " --build-arg #{build_arg}" } | ||
cmd += " #{config.app_dir}" | ||
cmd += " #{docker_context}" |
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.
What if docker_context is not set?
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.
yes, build_image sets this...
Summary by CodeRabbit
New Features
BuildImage
command to accept a custom Docker context.--docker-context
option to thebuild-image
command.Bug Fixes
run
command to fail with mismatched environment variables.