Google Launches Jib: The Containerizer for Java application

by | Sep 2, 2018 | Containers | 0 comments

The containers let the java developers closer than ever to a “write once, run anywhere” workflow, but containerizing a java application is not an easy task.

You have to write the Docker file, run docker daemon as root, wait for the build to complete and then push that image to the repositories.

This is not an easy task and also not all the java developers are expert in Java.

To handle this challenge two of Google engineers Appu Goundan and Qingyang Chen announces a new technology Jib which is an open-source Java “Containerizer,” one that handles all the steps of packaging your application into a container image.

It does not require the developer to write the docker file or have docker installed rather it is directly integrated into Apache Maven and Gradle by adding just the plugin to your build and you will have your Containerized Java application.

Docker Build Flow

Jib Build Flow

Benefits of development with Jib

 1. Simple – There are some issues with the development of Java application with Docker, You have to maintain the docker file, run a docker daemon or even worry about creating a fat JAR with all its dependencies.

While working with Jib the benefit is that the Jib is implemented in Java and runs as a part of Maven or Gradle build.

Since Jib is tightly integrated with Java build, it has access to all the necessary information to package your application. Any variations in your Java build are automatically picked up during subsequent container builds.

2. Fast – Jib separates the application into layers by splitting the dependencies from classes and takes the advantage of registry caching to achieve fast and incremental builds.

It reads the build configuration, organizes the application into distinct layers and only updates the layer that has changed.

Jab saves the valuable time by pushing only the updated layers to the repository instead of sending the whole application.

3. Reproducible – Jib supports building container images declaratively from your Maven and Gradle build metadata.

Also can be configured to create reproducible build images as long as your inputs remain the same.

How to use Jib to containerize your application

Jib is accessible as modules for Maven and Gradle and requires negligible design. Just add the module to your fabricate definition and design the objective picture.

In the event that you are working to a private registry, make a point to arrange Jib with certifications for your registry.

The least demanding approach to do this is to utilize accreditation assistants like docker-certification gcr. Jib likewise gives extra principles to building a picture to a Docker daemon on the off chance that you require it.

Jib on Maven

<plugin>
  <groupid>com.google.cloud.tools</groupid>
  <artifactid>jib-maven-plugin</artifactid>
  <version>0.9.0</version>
  <configuration>
    <to>
      <img>gcr.io/my-project/image-built-with-jib
    </to>
  </configuration>
</plugin>
# Builds to a container image registry.
$ mvn compile jib:build
# Builds to a Docker daemon.
$ mvn compile jib:dockerBuild

Jib on Maven

plugins {
  id 'com.google.cloud.tools.jib' version '0.9.0'
}
jib.to.image = 'gcr.io/my-project/image-built-with-jib'

# Builds to a container image registry.
$ gradle jib
# Builds to a Docker daemon.
$ gradle jibDockerBuild

For more information, you can visit the GitHub Repo