Skip to content

Latest commit

 

History

History
133 lines (112 loc) · 3.82 KB

jibplugin.adoc

File metadata and controls

133 lines (112 loc) · 3.82 KB

Jib maven plugin

Plugin configuration

      <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>jib-maven-plugin</artifactId>
        <version>3.3.1</version>
        <dependencies>
          <dependency>
            <groupId>com.google.cloud.tools</groupId>
            <artifactId>jib-layer-filter-extension-maven</artifactId>
            <version>0.3.0</version>
          </dependency>
        </dependencies>
        <configuration>
          <to>
            <image>localhost:5000/firstimage/${project.artifactId}</image>
            <tags>
              <tag>latest</tag>
            </tags>
          </to>
          <from>
            <image>eclipse-temurin:11</image>
          </from>
          <container>
            <entrypoint>INHERIT</entrypoint>
            <args>
              <arg>jshell</arg>
            </args>
          </container>
          <allowInsecureRegistries>true</allowInsecureRegistries>

          <extraDirectories>
            <paths>
              <path>
                <from>../context</from>
                <into>/deployments</into>
              </path>
            </paths>
          </extraDirectories>
          <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>
                  <!-- Delete all jar files added automatically by jib. -->
                  <filter>
                    <glob>/app/**</glob>
                  </filter>
                </filters>
              </configuration>
            </pluginExtension>
          </pluginExtensions>
        </configuration>
      </plugin>

By default the plugin send all the content to the app folder :

  • /app/lib : all the dependencies

  • /app/resources : the application.properties file

  • /app/jib-classpath-file: runtime classpath that Jib would use for default app launch

  • /app/jib-main-class-file: main class

Default image
Figure 1. Default image

To build a valid image, the following are needed:

  • the extra directories to send all the context content as it is in /deployments/dependencies

  • the Layer-Filter Extension to remove the app folder

The maven command used is jib:build. An example would be :

mvn -e jib:build -Dmaven.repo.local=/tmp/artifacts/m2 --global-settings /tmp/kit-cfkvvqjdm89s73c9irb0-351212210/maven/settings.xml -Dmaven.artifact.threads=12 -T 12

Incremental build

✔️
Incremental build is validated
First image
Figure 2. First image
Second image
Figure 3. Second image
Third image
Figure 4. Third image

Multi-architecture

✔️
Multi-architecture is validated

The JIB maven plugins allow to configures platforms of base images to select from a manifest list.

          <from>
            <image>eclipse-temurin:11</image>
            <platforms>
              <platform>
                <architecture>amd64</architecture>
                <os>linux</os>
              </platform>
              <platform>
                <architecture>arm64</architecture>
                <os>linux</os>
              </platform>
            </platforms>
          </from>