38

Jib, a Java Container Image Builder from Google

 6 years ago
source link: https://www.tuicool.com/articles/hit/iUbIJ3J
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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 developer application and its runtime dependencies. The following images compare the Docker and Jib build flows:

Docker build flow:

image1-1534907160012.png

Jib build flow:

image2-1534907159745.png

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 .


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK