Spring Boot 使用 Jib 打包成 Docker 镜像
Spring Boot Docker About 1,917 wordsMaven 插件
使用本地镜像:以docker://
标识。
默认的基础镜像是openjdk:11-jre
,每次都会去镜像仓库拉取。
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<from>
<image>docker://openjdk:11-jre-slim</image>
</from>
<to>
<image>my-${project.artifactId}</image>
<tags>
<tag>${project.version}</tag>
</tags>
<!--<auth>-->
<!-- <username></username>-->
<!-- <password></password>-->
<!--</auth>-->
</to>
<container>
<workingDirectory>/app</workingDirectory>
<jvmFlags>
<jvmFlag>-Xms10m</jvmFlag>
<jvmFlag>-Xmx20m</jvmFlag>
</jvmFlags>
<environment>
<MY_ENV1>my_env1_value1</MY_ENV1>
<MY_ENV2>my_env1_value2</MY_ENV2>
</environment>
<ports>
<port>8080</port>
<port>5005</port>
</ports>
</container>
</configuration>
<!-- 执行 mvn package 阶段时会同时执行 jib:dockerBuild -->
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
构建本地镜像
jib:dockerBuild
参考文档
https://github.com/GoogleContainerTools/jib/tree/master/jib-maven-plugin
开源地址
Views: 1,626 · Posted: 2023-01-26
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...