linux怎么查看本机内存大小
374
2022-10-25
DevOps之docker自动化部署java应用
2、项目根目录settings.gradle添加以下内容,各个部署单元覆写该值
ext{ //优先级低,各模块docker-build时会覆写该参数 dockerTag = "dev" dockerGroup = "devops"//与harbor控制台【项目】对应。 }
3、部署单元build.gradle文件添加以下内容,pushImage名称不能修改,代码中有调用这个task:
buildscript { dependencies { //新增以下行.... classpath "com.bmuschko:gradle-docker-plugin:3.2.1" } } //新增以下行.... apply plugin: 'com.bmuschko.docker-java-application' dependencies { //新增以下行.... compile group: 'org.gradle', name: 'gradle-tooling-api', version: '4.3' } //追加以下内容,docker构建相关task: task cleanDocker(type: Delete) { delete fileTree("${buildDir}/docker") { include '**/*' } } task copyDockerJar(type: Copy, dependsOn: build) { group = "docker" dependsOn cleanDocker from "Dockerfile",jar.archivePath.path into "${project.buildDir}/docker" rename { String fileName -> fileName.replace("-${project.version}", "") } } docker{ registryCredentials { url = 'http://{docker-damon-ip}:5678' username = 'harbor-user' password = 'harbor-user-passwd' } } import com.bmuschko.gradle.docker.tasks.image.* task buildImage(type: DockerBuildImage,dependsOn: copyDockerJar) { def destFile = file("Dockerfile") group = "docker" //inputDir = destFile.parentFile inputDir = file("${project.buildDir}/docker") tags = [ "harbor.anji-allways.com/${dockerGroup}/${project.name}:${dockerTag}".toString() ] } task tagImage(type: DockerTagImage,dependsOn: buildImage){ imageId = '' repository = "harbor.anji-allways.com/${dockerGroup}/${project.name}" tag = "${dockerTag}" doFirst{ imageId = buildImage.getImageId() } } task pushImage(type: DockerPushImage,dependsOn: tagImage){ imageName = tagImage.repository tag = tagImage.tag doLast{ delete fileTree("${buildDir}/docker") { include '**/*' } } }
手工执行docker任务,测试:
/*gradle ops-api-feign:pushImage -xTest -PdockerTag=dev1.0.3 -PdockerGroup=devops*/ /*执行 gradle [subproject]:pushImage -xTest 打包上传镜像,dockerTag,dockerGroup不要修改*/
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~