在Gradle中使用jib自动打包
jib是一个自动打包发布工具,可以编译打包成Docker镜像,推送到镜像仓库
# 导入插件
plugins {
id "com.google.cloud.tools.jib" version "2.6.0"
}
1
2
3
2
3
# 配置
jib {
//基础镜像
from {
image = 'domain.com/library/openjdk:11.0.7-jre-slim'
}
//目标仓库
to {
image = "domain.com/namespace/${artifactId}"
//末尾加上时间戳
tags = ['latest', "${project.version}" + "-" + LocalDate.now().toString()]
auth {
username = 'dev' // Defined in 'gradle.properties'.
password = 'dev'
}
}
//虚拟机参数
container {
creationTime = 'USE_CURRENT_TIMESTAMP'
jvmFlags = ['-Duser.timezone=Asia/Shanghai', '-Djava.security.egd=file:/dev/./urandom']
}
//支持HTTP协议
allowInsecureRegistries = true
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 使用
gradle jib
1
上次更新: 10/23/2024