Closed daromnik closed 8 months ago
Ultimately, I achieved the desired result with the help of the following changes in the settings of the jib-maven-plugin plugin:
1) add dependency to the plugin jib-layer-filter-extension-maven - this is for managing layers when creating an image:
<dependencies>
<dependency>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-layer-filter-extension-maven</artifactId>
<version>0.3.0</version>
</dependency>
</dependencies>
2) Add extraDirectories so that fat jar formed by spring boot is included to the image:
<extraDirectories>
<paths>
<path>
<from>target</from>
<into>/app/classpath</into>
<includes>*.jar</includes>
</path>
</paths>
</extraDirectories>
3) Then in pluginExtensions we delete the old jar that created jib and delete libs, because all libs are in our fat jar from spring:
<pluginExtensions>
<pluginExtension>
<implementation>com.google.cloud.tools.jib.maven.extension.layerfilter.JibLayerFilterExtension</implementation>
<configuration implementation="com.google.cloud.tools.jib.maven.extension.layerfilter.Configuration">
<filters>
<filter>
<glob>/app/classpath/*.original.jar</glob>
</filter>
<filter>
<glob>/app/libs/*.jar</glob>
</filter>
</filters>
</configuration>
</pluginExtension>
</pluginExtensions>
4) And we add the correct entry point of our jar for spring (if we have spring boot >= 3.2, then the class will be different org.springframework.boot.loader.launch.JarLauncher):
<entrypoint>java,-cp,@/app/jib-classpath-file,org.springframework.boot.loader.JarLauncher</entrypoint>
As a result, fat jar will simply lie in /app/classpath folder. If you do everything through jib-cli, then instead of fat jar there will be an unpacked jar in the /app folder.
Hello.
Sorry that perhaps this is not the place to write. I have a question, I couldn’t find information on it in the faq.
I'm using spring boot + proguard + jib. I was able to get my jar to load into docker and run successfully via jib-cli.
ex: jib jar --target docker://myregistry/auth auth-0.0.1.jar --from baseimage
But is there a way to arrange all this through pom.xml of my service via jib-maven-plugin?
Here https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#i-want-to-containerize-a-jar it is written about