-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
containerizingMode = 'packaged' does not work with Spring Boot in Gradle #1851
Comments
The one issue, and I think @chanseokoh can confirm, is that this isn't support for fatJar types. It's just Jars with dependencies still added into the container separately. |
Hmm... this sounds familiar. I wonder if we should do the same for But as @loosebazooka mentioned, you should avoid containerizing a fat JAR, as it results in duplicating dependencies. So, I think this issue is basically a feature request to support containerizing a fat JAR. |
Hi @loosebazooka, thank you for quick reply, I actually just opened another issue about that #1852, though it would be separate problems (If it's by design, both will be quickly closed I guess). I'm pretty new to building Java apps/Gradle, I'm probably missing some pieces. |
@maxbrunet I am trying this now. But I just realized that even though your workaround makes Jib pick up the fat JAR that Spring Boot generates, the image doesn't actually work. The entrypoint Jib generates is |
Yes, I had overwritten the entrypoint with |
Are you doing I'm asking these questions because my plan to support the "package" mode for Spring Boot is to make Jib pick up the original JAR instead of the Spring Boot-generated fat JAR. This will jsut automatically work without requiring changing an entrypoint or anything; it will just use the original thin JAR and do |
Yes, I did |
@maxbrunet so the best workaround for you should be to enable the
so enabling the
But then
or
Then Jib will make use of the normal JAR instead of the fat JAR. This will let you avoid duplicating dependencies packaged in the fat JAR. Also this does not require you to manually override the entrypoint to something like |
#2178 basically resolves this issue. In the next release, you won't need any special workaround and Jib will just work. In fact, Jib will automatically implement the workaround above (enabling the The issue title (which I renamed so at some past point) talks about a potential feature to allow specifying a custom JAR task or path. But re-evaluating the current state, I think the feature is unnecessary (even for other app frameworks). The real issue was that We'll let you know once we have a new release out. |
@maxbrunet We've released 2.0.0, which contains this fix! |
Hi, I am getting this error in maven: Execution default-cli of goal com.google.cloud.tools:jib-maven-plugin:2.7.0:dockerBuild failed: Are you going to support WAR in package mode? I am struggling to build an image that uses the spring-boot tomcat embedded container in a WAR package. |
We don't have a plan. Given #1802 (comment) and the priority, unfortunately I don't think we will work on it anytime soon. Also particularly for WAR, we don't want to promote the packaged mode, as a WAR embeds all the app dependency JARs and leads to a very inefficient image layering. At the moment, you can remove
By the design of Jib, if your project has type |
Hi there!
We build our SpringBoot application with a
BootJar
task (which inherits fromJar
) in Graddle, and the newcontainerizingMode = 'packaged'
feature hard-codes the task name tojar
:jib/jib-gradle-plugin/src/main/java/com/google/cloud/tools/jib/gradle/GradleProjectProperties.java
Lines 213 to 218 in e3e3638
Would it possible to have this name configurable?
Like:
(or pass the task object directly, or even explicitly the path to the jar file)
I have currently worked around that by pointing the attributes of
jar
tobootjar
:I guess another alternative could be (not tested and I'd like not to have to rename my
bootJar
task):The text was updated successfully, but these errors were encountered: