-
-
Notifications
You must be signed in to change notification settings - Fork 649
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 image output field to support publish to repository when using BuildKit #20154
Conversation
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.
Very nice. This will make it much easier to get into build kit mode :)
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.
We're getting closer :)
error_cls=DockerImageOptionValueError, | ||
) | ||
yield from target[field_type].options(format) | ||
elif issubclass(field_type, DockerBuildKitOptionField): |
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.
sorry, but I have an itch to scratch here. I think I may have an idea how to further improve this logic slightly.
There are two things going on here now, one is validating option use and the other is to produce the option values themselves.
Looking at this elif chain, I fear it'll be too easy to add a new option that inherits from both DockerBuildOptionFieldMixin
and DockerBuildKitOptionField
and then you don't get the behaviour we want.
How about splitting this into two elif chains. The first for option validation (such as the use buildx toggle for buildkit options) and the other for producing the option values. That would also get rid of the duplication we have now.
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.
Seems a lot cleaner now - let me know
@@ -347,7 +350,7 @@ def get_build_options( | |||
source=source, | |||
error_cls=DockerImageOptionValueError, | |||
) | |||
yield from target[field_type].options(format) | |||
yield from target[field_type].options(format, global_build_hosts_options=global_build_hosts_options) # type: ignore[attr-defined] |
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.
I assume this is a mypy bug but couldn't find any workaround. It seems to occur when there are more than 2 subclasses added to issubclass
- e.g. splitting into separate if
statements for each subclass doesn't trigger it.
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.
interesting. we can go with this for now.. I'll have a look on my end, if I'll find anything I can follow up in a new PR in that case.
@@ -347,7 +350,7 @@ def get_build_options( | |||
source=source, | |||
error_cls=DockerImageOptionValueError, | |||
) | |||
yield from target[field_type].options(format) | |||
yield from target[field_type].options(format, global_build_hosts_options=global_build_hosts_options) # type: ignore[attr-defined] |
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.
interesting. we can go with this for now.. I'll have a look on my end, if I'll find anything I can follow up in a new PR in that case.
…sing BuildKit (#20154) Currently, the `publish` goal doesn't work with docker images when buildkit is enabled, as by [default buildkit doesn't save the build output locally](docker/buildx#166), and `publish` expects that the images were saved. This PR adds support for setting the output type, and defaults it to`docker`, which is the legacy docker build behavior, i.e. saves to the local image store. However, we only want to set that when buildkit is enabled. I thought it better to add an explicit option for that at the subsystem level; this allows for validation of buildkit-only options. This eliminates the need to set `DOCKER_BUILDKIT=1` in env vars - I need to update the docs on that actually. I have validated that with this change, docker images can be published to a registry. --------- Co-authored-by: Rhys Madigan <rhys.madigan@accenture.com>
I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants. ✔️ 2.19.xSuccessfully opened #20185. Thanks again for your contributions! |
I tried to automatically cherry-pick this change back to each relevant milestone, so that it is available in those older releases of Pants. ❌ 2.18.xI was unable to cherry-pick this PR to 2.18.x, likely due to merge-conflicts. Steps to Cherry-Pick locallyTo resolve:
Please note that I cannot re-run CI if a job fails. Please work with your PR approver(s) to re-run CI if necessary. ✔️ 2.19.xSuccessfully opened #20185. When you're done manually cherry-picking, please remove the Thanks again for your contributions! |
…sing BuildKit (Cherry-pick of #20154) (#20185) Currently, the `publish` goal doesn't work with docker images when buildkit is enabled, as by [default buildkit doesn't save the build output locally](docker/buildx#166), and `publish` expects that the images were saved. This PR adds support for setting the output type, and defaults it to`docker`, which is the legacy docker build behavior, i.e. saves to the local image store. However, we only want to set that when buildkit is enabled. I thought it better to add an explicit option for that at the subsystem level; this allows for validation of buildkit-only options. This eliminates the need to set `DOCKER_BUILDKIT=1` in env vars - I need to update the docs on that actually. I have validated that with this change, docker images can be published to a registry. Co-authored-by: riisi <rhysmadigan@gmail.com> Co-authored-by: Rhys Madigan <rhys.madigan@accenture.com>
@huonw apologies, my bad I got this feature mixed up with something else, so we only need it picked to 2.19. |
Currently, the
publish
goal doesn't work with docker images when buildkit is enabled, as by default buildkit doesn't save the build output locally, andpublish
expects that the images were saved.This PR adds support for setting the output type, and defaults it to
docker
, which is the legacy docker build behavior, i.e. saves to the local image store.However, we only want to set that when buildkit is enabled. I thought it better to add an explicit option for that at the subsystem level; this allows for validation of buildkit-only options.
This eliminates the need to set
DOCKER_BUILDKIT=1
in env vars - I need to update the docs on that actually.I have validated that with this change, docker images can be published to a registry.