BT

InfoQ Homepage News Jib, a Java Container Image Builder from Google

Jib, a Java Container Image Builder from Google

Leia em português

Bookmarks

Google recently announced Jib, an open-source container image builder that lets Java developers build Java containers using well-known Java tools such as Maven or Gradle. Developers are not required to write a Dockerfile or have Docker installed in order to build an image.

Jib is implemented in Java and runs as part of a Maven or Gradle build. Jib's build approach separates the Java application into multiple layers, so when there are any code changes, only those changes are rebuilt, rather than the entire application. By default, these layers are layered on top of a distroless base image, which is an image that contains only the developer's application and its runtime dependencies. The following images compare the Docker and Jib build flows:

Docker build flow:

Jib build flow:

To start using Jib, developers just need to add one of the available plugins for Maven or Gradle to the build file and configure the target image. Below are some examples illustrating a build to a container registry and a to a Docker daemon:

Maven

<plugin>
  <groupId>com.google.cloud.tools</groupId>
  <artifactId>jib-maven-plugin</artifactId>
  <version>0.9.0</version>
  <configuration>
    <to>
      <image>myimage</image>
    </to>
  </configuration>
</plugin>
# Builds to a container image registry.
$ mvn compile jib:build
# Builds to a Docker daemon.
$ mvn compile jib:dockerBuild

Gradle

plugins {
  id 'com.google.cloud.tools.jib' version '0.9.8'
}
jib.to.image = 'myimage'
# Builds to a container image registry.
$ gradle jib
# Builds to a Docker daemon.
$ gradle jibDockerBuild

For users who require authenticating with private registries, Jib provides Docker credential helpers. Users can also define credentials in their Maven settings. Some common credential helpers included are Google Container Registry, AWS Elastic Container Registry, and Docker Hub Registry. The following is an example using credential helpers:

<configuration>
  ...
  <from>
    <image>aws_account_id.dkr.ecr.region.amazonaws.com/my-base-image</image>
    <credHelper>ecr-login</credHelper>
  </from>
  <to>
    <image>gcr.io/my-gcp-project/my-app</image>
    <credHelper>gcr</credHelper>
  </to>
  ...
</configuration>

More information can be found on the GitHub repo.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.