springboot+Jib+Maven+Idea+Docker 实践

网友投稿 230 2022-10-21

springboot+Jib+Maven+Idea+Docker 实践

Jib - Containerize your Maven project

​​2. Jib+Maven+Springboot 实践代码例子​​

​​2.1在maven项目中的pom.xml文件中配置Jib插件​​​​2.2 配置详情​​​​2.2 运行效果展示:​​​​2.3 验证生成好的镜像:​​​​2.4 push镜像到镜像仓库:​​

用Jib配置idea的maven项目中,实现springboot、tomcat 来build镜像

2. Jib+Maven+Springboot 实践代码例子

2.1在maven项目中的pom.xml文件中配置Jib插件

com.google.cloud.tools jib-maven-plugin 1.0.1

pluginManagement & plugins 如果在idea右边不显示插件jib,注意把pluginManagement注释了,就可以正常显示了

2.2 配置详情

1.这里有一个验证直接使用用户名和密码,来替代credHelper使用。验证成功后可以直接从Docker hub或者网易hub.c.163.com上获取官方镜像(依据个人喜好配置对应的auth)

com.google.cloud.tools jib-maven-plugin 1.0.1 openjdk:alpine ${registry_username} ${registry_password} ${registry_url}/${project.artifactId} latest com.ecdata.CmpApplication true 8088 package dockerBuild

已绑定jib:build到 Maven生命周期package,所以直接运行package

2.2 运行效果展示:

[INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ cmp ---[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] skip non existing resourceDirectory /Users/ws/dev/sourceCode/ideaProjects/sw/cmp/src/test/resources[INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ cmp ---[INFO] Changes detected - recompiling the module![INFO] Compiling 13 source files to /Users/ws/dev/sourceCode/ideaProjects/sw/cmp/target/test-classes[INFO] [INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ cmp ---[INFO] Tests are skipped.[INFO] [INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ cmp ---[INFO] Building jar: /Users/ws/dev/sourceCode/ideaProjects/sw/cmp/target/cmp-0.0.1-SNAPSHOT.jar[INFO] [INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ cmp ---[INFO] [INFO] --- jib-maven-plugin:1.0.1:dockerBuild (default) @ cmp ---[WARNING] Setting image creation time to current time; your image may not be reproducible.[INFO] [INFO] Containerizing application to Docker daemon as 31.16.14.55/szy/cmp, 31.16.14.55/szy/cmp...[INFO] Getting base image openjdk:alpine...[INFO] Building dependencies layer...[INFO] Building resources layer...[INFO] Building classes layer...[INFO] The base image requires auth. Trying again for openjdk:alpine...[INFO] Retrieving registry credentials for registry.hub.docker.com...[INFO] [INFO] Container entrypoint set to [java, -cp, /app/resources:/app/classes:/app/libs/*, com.ecdata.CmpApplication][INFO] Loading to Docker daemon...[INFO] [INFO] Built image to Docker daemon as 31.16.14.55/szy/cmp, 31.16.14.55/szy/cmp[INFO] [INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 30.268 s[INFO] Finished at: 2019-02-27T09:55:16+08:00[INFO] ------------------------------------------------------------------------Process finished with exit code 0

2.3 验证生成好的镜像:

sai:~ ws$ docker images | grep 31.16.14.55/szy/cmp31.16.14.55/szy/cmp latest 70440c0ad660 6 minutes ago 213MBsai:~ ws$

2.4 push镜像到镜像仓库:

sai:~ ws$ docker push31.16.14.55/szy/cmp

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:关于mybatis遇到Integer类型的参数时动态sql需要注意条件
下一篇:Docker安装MongoDB
相关文章

 发表评论

暂时没有评论,来抢沙发吧~