-
-
Notifications
You must be signed in to change notification settings - Fork 673
Fix #22602: targets in extra_build_args #22603
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
base: main
Are you sure you want to change the base?
Conversation
I haven't forgotten about this, will try and get to it this weekend. |
Meanwhile the CI test failures look meaningful. |
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.
Thanks for the fix!
Having paged some of this backend into my brain, this seems right. But see my question, which will help me understand this better.
build_env: DockerBuildEnvironment, | ||
upstream_image_ids: Iterable[str], | ||
dockerfile_info: DockerfileInfo, | ||
should_suggest_renames: bool = True, |
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 has this been removed? The underlying option now doesn't do anything, looks like.
# Override default value type for the `build_args` context to get helpful error messages. | ||
interpolation_context["build_args"] = DockerBuildArgsInterpolationValue( | ||
interpolation_context.get("build_args", {}) | ||
merged_build_args_with_extensions |
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.
This change is quite subtle, so help me understand something...
This seems to be the critical line, where it's important for some reason that merged_build_args_with_extensions
is not converted to a DockerBuildArgsInterpolationValue
. Why does this fix the issue?
Summary
extra_build_args
inBUILD
filesDockerBuildContext.create()
to consistently use merged build args (includingextra_build_args
) for both interpolation context andDockerfile
stage parsingextra_build_args
override defaultARG
values inDockerfiles
Problem
Previously, when using target references like
:base-image
inextra_build_args
, Pants failed to resolve these to actual Docker image tags during build context creation. This prevented users from creating hierarchical Docker image dependencies and dynamic base image selection.Solution
The fix ensures that
extra_build_args
fromBUILD
files are properly merged and made available during all phases of build context creation, particularly when parsingDockerfile
stages that containFROM
instructions with variable substitution.Test Coverage
Added
test_from_image_build_arg_with_extra_build_args()
which validates:extra_build_args
extra_build_args
resolve to proper image tags