Introducing Jib — build Java Docker images better

news/2024/5/20 4:03:34 标签: docker, java, jid, maven, gradle

这是一篇来自于google的文章,对于java开发者来说很实用,尤其是容器天下的时代。值得仔细阅读。
引自

Containers are bringing Java developers closer than ever to a “write once, run anywhere” workflow, but containerizing a Java application is no simple task: You have to write a Dockerfile, run a Docker daemon as root, wait for builds to complete, and finally push the image to a remote registry. Not all Java developers are container experts; what happened to just building a JAR?

To address this challenge, we’re excited to announce Jib, an open-source Java containerizer from Google that lets Java developers build containers using the Java tools they know. Jib is a fast and simple container image builder that handles all the steps of packaging your application into a container image. It does not require you to write a Dockerfile or have docker installed, and it is directly integrated into Maven and Gradle—just add the plugin to your build and you’ll have your Java application containerized in no time.

Docker build flow:
在这里插入图片描述
Jib build flow:
在这里插入图片描述

How Jib makes development better

Jib takes advantage of layering in Docker images and integrates with your build system to optimize Java container image builds in the following ways:
Simple – Jib is implemented in Java and runs as part of your Maven or Gradle build. You do not need to maintain a Dockerfile, run a Docker daemon, or even worry about creating a fat JAR with all its dependencies. Since Jib tightly integrates with your 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.
Fast – Jib takes advantage of image layering and registry caching to achieve fast, incremental builds. It reads your build config, organizes your application into distinct layers (dependencies, resources, classes) and only rebuilds and pushes the layers that have changed. When iterating quickly on a project, Jib can save valuable time on each build by only pushing your changed layers to the registry instead of your whole application.
Reproducible – Jib supports building container images declaratively from your Maven and Gradle build metadata, and as such 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 available as plugins for Maven and Gradle and requires minimal configuration. Simply add the plugin to your build definition and configure the target image. If you are building to a private registry, make sure to configure Jib with credentials for your registry. The easiest way to do this is to use credential helpers like docker-credential-gcr. Jib also provides additional rules for building an image to a Docker daemon if you need it.

Jib on Maven

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

Jib on Gradle

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

We want everyone to use Jib to simplify and accelerate their Java development. Jib works with most cloud providers; try it out and let us know what you think at github.com/GoogleContainerTools/jib.


http://www.niftyadmin.cn/n/1053097.html

相关文章

php连接数据库 搜索数据形成数组,转为字符串

<?php //连接数据库 $db new mysqli(localhost,root,root,z_0222); !mysqli_connect_error() or die(数据库连接失败); $db->query(set names utf8); //搜索语句 $sql "select * from student";$res $db->query($sql); //转为数组 $arr $res->fetc…

CSS省略号text-overflow超出溢出显示省略号

http://www.divcss5.com/rumen/r532.shtml转载于:https://www.cnblogs.com/tanhao/p/8134483.html

vue学习笔记之初识vue——模板声明与绑定

模板的存在的唯一目的&#xff0c;是为了和数据绑定。 Vue.js在标准HTML语法基础上&#xff0c;增加了一些扩展的语法来声明数据的绑定。 数据绑定语法 在Vue.js的模板中&#xff0c;最常见的一种数据绑定语法&#xff0c;是使用模板引擎Mustache 的插值写法&#xff1a;{{}}。…

一个历时五天的 Bug

一个程序员在没有成长成为架构师之前&#xff0c;几乎都要跟 Bug为伴&#xff0c;程序员有很多时间都是花在了查找各种 Bug上。 我印象深刻的一个Bug, 是一个服务器网络框架无锁队列的 Bug 。那个 Bug 连续查找了五天的时间&#xff0c;才最后定位出来。 当时我们的分布式存储系…

Spring Data Cassandra 轻量级事物支持

Spring Data Cassandra 轻量级事务支持 做数据操作不得不提的就是数据操作的事务性&#xff0c;如果控制不好就很容易将数据写脏&#xff0c;这往往是初学者容易犯大忌的地方。我们来看一下Spring Data Cassandra是如何给我们的数据操作增加轻量级事务支持的。 从Spring Data…

XML解析器

解析器的主要功能就是检查XML文件是否有结构上的错误&#xff0c;剥离XML文件中的标记&#xff0c;读出正确的内容&#xff0c;以交给下一步的应用程序处理。XML是一种用来结构化文件信息的标记语言&#xff0c;XML规范中对于如何标记文件的结构性有一个详细的法则&#xff0c;…

Python读csv文件去掉一列后再写入新的文件

用了两种方式解决该问题&#xff0c;都是网上现有的解决方案。 场景说明&#xff1a; 有一个数据文件&#xff0c;以文本方式保存&#xff0c;现在有三列user_id,plan_id,mobile_id。目标是得到新文件只有mobile_id,plan_id。 解决方案 方案一&#xff1a;用python的打开文件写…

Win7 + VirtualBox安装Mac OS X雪豹操作系统图文详解[转]

由于工作需要&#xff0c;我需要同时使用Windows和Mac OS X操作系统&#xff0c;虽然公司可以配置两台机器&#xff0c;但是出于发热量&#xff0c;空间占用&#xff0c;操作系统互通等原因&#xff0c;我还是更倾向于在虚拟机环境里工作。由于在大部分工作还是在Windows上完成…