You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to test an optimization and need a way to signal container_image to write slightly different tarballs.
I will start by adding experimental_tarball_format to container_image, with all kinds of warnings that people should not depend on it, but let's revisit the overall API after I've validated my hypothesis.
Mostly opening this as a stub so I can TODO(#${issue}) it.
In terms of landing this "for real", would it make sense to have a new rule called container_save that is the dual of container_load and handles serializing container_image to disk?
We could have (at least) three formats:
"legacy"
"compressed"
"layout"
I'm not sure if this is bazel-idiomatic or not (cc @smukherj1)?
I don't have the context for why the way this currently works is via :container-image.tar, maybe @mattmoor can shed light on that?
@alexeagle Matt pointed me at you when I asked for "someone who cares about idiomatic bazel stuff", sorry 😉
I'm trying to figure out what is more bazel-y an option. Currently, you can serialize a container_image to a tarball by building it with .tar appended to the target name. This made sense in 2015, when there was one form of docker tarball, but there are now three tarball formats in common use. I was experimenting with this by just adding an attribute to container_image to control the tarball format (see linked PR), but this feels kind of gross, because the attribute only applies when building the .tar.
In my head, it seems reasonable to have a separate container_save rule that is exclusively concerned with serializing other container_* things to disk.
Which of those options feels better to you?
Also, if you're willing to let me waste more of your time, and if you care about container images in general, I'd love it if you could tear apart my strawman proposal for rules for assembling multi-platform images in #300 (comment). I know a bit about containers, but not much at all about bazel.
feels to me that if the container_image can produce three different tarballs, there should be three different predeclared outputs so you can request the one you want. They'd have to have distinct paths in the output tree as well (thing.formatA.tgz or sth). Bazel semantics are that it only runs actions needed to produce the requested outputs, and by predeclaring them the user can ask for the one they want.
Adding another rule is maybe useful if there's some novel composition users need where they use a container_save in conjunction with something other than container_image but my guess is you just want to declare more outputs.
First of all, thank you for your time 😄 a lot of this is me just thinking out loud, and I would of course appreciate your guidance on any of it, but I've tried to only mention folks in places where I have specific questions.
there should be three different predeclared outputs so you can request the one you want. They'd have to have distinct paths in the output tree as well (thing.formatA.tgz or sth). Bazel semantics are that it only runs actions needed to produce the requested outputs, and by predeclaring them the user can ask for the one they want.
This makes some sense to me. In fact, we were thinking about punning this "compressed" form as thing.tar.gz, but it actually would make more sense to be thing.gz.tar (or something) to avoid confusing people into thinking the output tarball is compressed (instead of the inner tarballs). So with this approach, we'd have thing.tar, thing.gz.tar, and thing.oci.tar. I'd be okay with this, but...
Adding another rule is maybe useful if there's some novel composition users need where they use a container_save in conjunction with something other than container_image
So, I think there is actually a novel composition here with other rules, and you've made me think of another argument for a new rule. The end result is that I'd like to write stuff out to a tarball in a new, incompatible format that is more generic than the currentdocker save tarballs. With the linked PR, we basically just compress the tarballs and name things slightly differently, but most clients that can read the legacy tarballs still work with these compressed tarballs, so nothing really breaks.
I want to write things out in this format which isn't readable by older clients that don't understand it (though... we can massage things a bit to trick them into reading it, which I might end up doing).
This new format would work with both single images, a collection of images (e.g. container_bundle -- though they would do roughly the same thing...), layers (container_layer), or really any arbitrary thing that has a media type (this ties in with #300 a bit, actually, since they share data structures, and we could use container_descriptor to hack a media type onto anything). You can see in the example at the bottom writing an application/xml file into this makes sense, so maybe container_save is too specific and this should be oci_layout or something... though I primarily want to use it to save containers :)
tl;dr, I'm thinking that because:
this would (usually) be a breaking change, and
we can compose this with any number of other rules,
it would make sense to promote this from just an attribute on a few rules to a full-blown new rule.
but my guess is you just want to declare more outputs.
@alexeagle Given the above, do you still think this would be the right approach? I might even be more confused now...
My thinking, in the fullness of time:
We drop the experimental_tarball_format attribute and just add a new ${IMAGE_TARGET}.gz.tar output, probably also make this work for container_bundle.
Implement a new rule that handles writing to an OCI image layout, which will just write to a directory by default (not sure how to reconcile with the intermediate form) with bazel build $OCI_TARGET, but can be bundled into a tar with bazel build ${OCI_TARGET}.tar. I'm not sure if calling this oci_layout or container_save is better 🤷
We could have an attribute that signals bazel to write more files (see Include manifest in the v1 tarball? Or latest OCI image-spec? google/go-containerregistry#651 for way more details, cc @deitch) into this to trick older clients into loading it as a normal docker save tarball, which makes me lean towards container_save, if we're going to have conainer-specific options, but now I'm going in circles...
Maybe this rule should just be called container_index so we don't end up with another rule when I go to implement multi-arch support.
Lots to consider :) perhaps an interim step (1.5) will be having thing.tar, thing.gz.tar, and thing.oci.tar on container_image and container_bundle, since that requires less design up front, then create a separate issue for a new rule.
@smukherj1 what do you think? Step 1 seems uncontroversial and you will probably see a PR from me to do this. Step 1.5 probably require a small amount of code review, but does that seem reasonable? Step 2, I imagine, would require some design review, but I'm happy to punt on that for now.
If I ever get around to doing the new rule, we could make the bazel build thing.oci.tar output essentially just be an alias for bazel build :thing_index.tar where:
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
I believe it's just a matter of plumbing the property through, which would be straightforward. Long term, I'd want to just remove this property and make compressed the default as part of switching over to OCI image layout as the on-disk and tarball format, but that's a bit more work.
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
Activity
jonjohnsonjr commentedon Dec 14, 2020
In terms of landing this "for real", would it make sense to have a new rule called
container_savethat is the dual ofcontainer_loadand handles serializingcontainer_imageto disk?We could have (at least) three formats:
I'm not sure if this is bazel-idiomatic or not (cc @smukherj1)?
I don't have the context for why the way this currently works is via
:container-image.tar, maybe @mattmoor can shed light on that?jonjohnsonjr commentedon Dec 14, 2020
@alexeagle Matt pointed me at you when I asked for "someone who cares about idiomatic bazel stuff", sorry 😉
I'm trying to figure out what is more bazel-y an option. Currently, you can serialize a
container_imageto a tarball by building it with.tarappended to the target name. This made sense in 2015, when there was one form of docker tarball, but there are now three tarball formats in common use. I was experimenting with this by just adding an attribute tocontainer_imageto control the tarball format (see linked PR), but this feels kind of gross, because the attribute only applies when building the.tar.In my head, it seems reasonable to have a separate
container_saverule that is exclusively concerned with serializing other container_* things to disk.Which of those options feels better to you?
Also, if you're willing to let me waste more of your time, and if you care about container images in general, I'd love it if you could tear apart my strawman proposal for rules for assembling multi-platform images in #300 (comment). I know a bit about containers, but not much at all about bazel.
alexeagle commentedon Dec 18, 2020
hi! That's nice of Matt to think of me ;)
feels to me that if the
container_imagecan produce three different tarballs, there should be three different predeclared outputs so you can request the one you want. They'd have to have distinct paths in the output tree as well (thing.formatA.tgz or sth). Bazel semantics are that it only runs actions needed to produce the requested outputs, and by predeclaring them the user can ask for the one they want.Adding another rule is maybe useful if there's some novel composition users need where they use a
container_savein conjunction with something other thancontainer_imagebut my guess is you just want to declare more outputs.jonjohnsonjr commentedon Dec 18, 2020
First of all, thank you for your time 😄 a lot of this is me just thinking out loud, and I would of course appreciate your guidance on any of it, but I've tried to only mention folks in places where I have specific questions.
This makes some sense to me. In fact, we were thinking about punning this "compressed" form as
thing.tar.gz, but it actually would make more sense to bething.gz.tar(or something) to avoid confusing people into thinking the output tarball is compressed (instead of the inner tarballs). So with this approach, we'd havething.tar,thing.gz.tar, andthing.oci.tar. I'd be okay with this, but...So, I think there is actually a novel composition here with other rules, and you've made me think of another argument for a new rule. The end result is that I'd like to write stuff out to a tarball in a new, incompatible format that is more generic than the current
docker savetarballs. With the linked PR, we basically just compress the tarballs and name things slightly differently, but most clients that can read the legacy tarballs still work with these compressed tarballs, so nothing really breaks.I want to write things out in this format which isn't readable by older clients that don't understand it (though... we can massage things a bit to trick them into reading it, which I might end up doing).
This new format would work with both single images, a collection of images (e.g.
container_bundle-- though they would do roughly the same thing...), layers (container_layer), or really any arbitrary thing that has a media type (this ties in with #300 a bit, actually, since they share data structures, and we could usecontainer_descriptorto hack a media type onto anything). You can see in the example at the bottom writing anapplication/xmlfile into this makes sense, so maybecontainer_saveis too specific and this should beoci_layoutor something... though I primarily want to use it to save containers :)tl;dr, I'm thinking that because:
it would make sense to promote this from just an attribute on a few rules to a full-blown new rule.
@alexeagle Given the above, do you still think this would be the right approach? I might even be more confused now...
My thinking, in the fullness of time:
experimental_tarball_formatattribute and just add a new${IMAGE_TARGET}.gz.taroutput, probably also make this work forcontainer_bundle.bazel build $OCI_TARGET, but can be bundled into a tar withbazel build ${OCI_TARGET}.tar. I'm not sure if calling thisoci_layoutorcontainer_saveis better 🤷docker savetarball, which makes me lean towardscontainer_save, if we're going to have conainer-specific options, but now I'm going in circles...container_indexso we don't end up with another rule when I go to implement multi-arch support.Lots to consider :) perhaps an interim step (
1.5) will be havingthing.tar,thing.gz.tar, andthing.oci.taroncontainer_imageandcontainer_bundle, since that requires less design up front, then create a separate issue for a new rule.@smukherj1 what do you think? Step 1 seems uncontroversial and you will probably see a PR from me to do this. Step 1.5 probably require a small amount of code review, but does that seem reasonable? Step 2, I imagine, would require some design review, but I'm happy to punt on that for now.
If I ever get around to doing the new rule, we could make the
bazel build thing.oci.taroutput essentially just be an alias forbazel build :thing_index.tarwhere:And we can do the same for
container_bundle, but the tag keys would becomeorg.opencontainers.image.ref.nameannotations on the descriptors.github-actions commentedon Jun 22, 2021
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
jonjohnsonjr commentedon Jun 22, 2021
So, #1696 had fantastic results for our use case, so I see a couple options:
experimental_prefix and maketarball_formata "real" thing, but I'm not sure what the most idiomatic approach would be, as described above.andyliuliming commentedon Sep 12, 2021
any plans to support this for "container_bundle"?
jonjohnsonjr commentedon Sep 13, 2021
I believe it's just a matter of plumbing the property through, which would be straightforward. Long term, I'd want to just remove this property and make compressed the default as part of switching over to OCI image layout as the on-disk and tarball format, but that's a bit more work.
github-actions commentedon Mar 13, 2022
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!
github-actions commentedon Apr 12, 2022
This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"