bazel-contrib / rules_oci

Bazel rules for building OCI containers
Apache License 2.0
305 stars 159 forks source link

FR: New rule `oci_image_binary` with dockerc (compile container image to a binary) #689

Closed zhouhaibing089 closed 1 month ago

zhouhaibing089 commented 2 months ago

I came across this Nilslrl/dockerc repository, which demonstrated the capability to compile docker images into binaries. While I just tried a few of the examples listed there, I see a great potential using it to build a new bazel rule. Just like cc_binary which compiles cpp source files into a binary, likely we can build something like oci_image_binary which takes an oci image tarball (or layout dir) and builds a binary out of it.

The output can then be referenced in other rules as tools or whatever.

I have to admit that I didn't look into how it is implemented (like does it actaully work with oci images) and also it only supports linux at this moment (though other platforms are in the roadmap).

Looking for people's thoughts here.

thesayyn commented 2 months ago

Could you elaborate on how this fits into this repo?

zhouhaibing089 commented 2 months ago

I assume rules_oci offers general useful rules to deal with oci images, and something like oci_image_binary seems to be a useful addition to be part of scope here. Maybe I fundamentally misunderstood something?

In the best case, if people like this idea, I would like to contribute, or in the worst case, people may find this idea interesting and build something cool on top of it in their own projects (like running some tests with a tool built from oci_image).

thesayyn commented 1 month ago

I don't see how this project fits into rules_oci as its a ruleset for creating OCI-compilant container images, not compile container images into binaries.

It's a cool tool indeed but i don't it belongs in rules_oci.

thesayyn commented 1 month ago

I am going to close this as there is no action for us to take here.