-
Notifications
You must be signed in to change notification settings - Fork 50
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
Implement Docker/OCI layer index file support #69
Comments
One thing that might be nice would be to have a |
Thanks for feedback. We also use rules_docker to package up our springboot apps, and have had good success with it. I am a little worried about building too much into the rules_spring repo, so I am not sold on springboot_image. But it is worth looking into it for sure. We are finding that external rules that bring in other dependencies (e.g. if rules_spring depended on rules_docker) are a pain to deal with. Bazel Federation just didn't take off unfortunately. What I have on the books right now is Issue #94 which is to just provide an example of how to build the docker image by combining springboot rule with rules_docker rules. But, once we implement this layer support, there may be a useful reason to also provide a springboot_image rule so we should consider it. |
@plaird do you have an example of that just for yourself? is it as easy adding the target and main to a container_image? |
@Marcus-Rosti we use
where
|
and @chrismgrayftsinc foo-service.jar is the output of
|
In this case, it looks like it would be the output of the springboot rule (which would need a different name from your library). Assuming you named the springboot rule "mrosti-service", then "foo-service.jar" would be replaced by "mrosti-service.jar". |
@chrismgrayftsinc that worked like a charm! thanks! |
Thanks @Marcus-Rosti for the question, and @chrismgrayftsinc for providing the example. Internally we do some additional fancy pants stuff around custom entrypoints, but what Chris provided covers the 95% case. |
@plaird I went ahead and started a small repo that does this. I heavily modified the springboot.bzl file to do it. I will need to clean it up, but for now it appears to work for our use case. Check it out at https://github.com/chrismgrayftsinc/rules_spring_image |
@chrismgrayftsinc I am looking forward to look at your solution. This week is crazy, but I am hoping to get to this soon. Thanks! |
@chrismgrayftsinc I think you are underselling what you have done - it is more than just layer file support. You also have done a bunch of the needful of migrating off of bash #3 which is the oldest open issue in the project. :) I have a bunch of things in flight right now outside of rules_spring, but I will try to prioritize finding a way to merge your work. I was thinking of using Java based on singlejar for the new rule impl in #3, but if we can get there with Starlark all the better. |
Spring Boot 2.3 added the ability to supply a layer index file that optimizes the writing of the Spring Boot jar for container use cases. It splits the jar into multiple layers.
Much like the classpath index file #33, we need to add an attribute so the user can supply the layer index. I don't think we should do anything magical here (i.e. auto-generating these files). Just allow the user to specify an existing workspace file as an attribute in the rule. This would be optional as the default layout seems sufficient for most use cases.
But then the writing of the spring boot jar file needs to honor the layers. This will involve having an alternate layout. This article explains everything pretty well:
To make this useful, the user would then need to create a docker image from the layered jar. This involves the
-Djarmode=layertools
tool. It is questionable if we should provide docker image creation support for this or not. At this point, I am more in favor of just showing examples.This work may require changing the springboot rule signature in some incompatible way, so assigning to a major release for now.
The text was updated successfully, but these errors were encountered: