Git Product home page Git Product logo

Comments (1)

daromnik avatar daromnik commented on May 26, 2024

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>
  1. 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>
  1. 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>
  1. 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.

from jib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.