gradle 制作 docker 镜像并推送到远程仓库

598人浏览 / 0人评论
def image_name = project.hasProperty('image_name') ? image_name : "micro-knowledge-manage-service"
def project_group = project.hasProperty('project_group') ? project_group : "base"

task copyBuildFile(type: Copy, dependsOn: bootJar) {
    from "build/libs/micro-knowledge-manage-service-${version}.jar"
    into "build/docker"
    from "Dockerfile"
    into "build/docker"
}

task buildImage(type: DockerBuildImage, dependsOn: copyBuildFile) {
    inputDir = project.file('build/docker')
    images.add("hdecharbor.ecidi.com/dam/${project_group}/${image_name}:1.0")
}

task pushImage(type: DockerPushImage, dependsOn: buildImage) {
    images.add("hdecharbor.ecidi.com/dam/${project_group}/${image_name}:1.0")
    registryCredentials.url = 'https://hdecharbor.ecidi.com/'
    registryCredentials.username = 'liu_x'
    registryCredentials.password = 'Liux@2020'
}

全部评论