buildscript { repositories { mavenCentral() } dependencies { classpath('se.transmode.gradle:gradle-docker:1.2') } } apply plugin: 'docker' apply plugin: 'application' dependencies{ compile project(':envir-config') //监控 compile('org.springframework.boot:spring-boot-starter-actuator') compile("de.codecentric:spring-boot-admin-starter-server") compile("de.codecentric:spring-boot-admin-starter-client") compile('org.jolokia:jolokia-core') compile('io.projectreactor.addons:reactor-extra') } //复制jar到指定的文件夹中 task copyJar() { print('copy jar ') copy { from("build/libs/zen-web-${version}.jar") into('../envir-jar/') } } bootJar { enabled = true } jar { enabled = false } docker{ baseImage 'openjdk:8-jre-alpine' maintainer 'tina 976056042@qq.com' registry 'registry.cn-qingdao.aliyuncs.com' } task dockerBuilder(type: Docker) { registry='registry.cn-qingdao.aliyuncs.com/gxzc-envir' applicationName = 'registry' tagVersion = jar.version addFile("./${jar.baseName}-${jar.version}.jar","app.jar") entryPoint(["java","-XX:+UnlockExperimentalVMOptions","-XX:+UseCGroupMemoryLimitForHeap","-Djava.security.egd=file:/dev/./urandom","-Duser.timezone=GMT+08","-jar",'app.jar']) exposePort(11010) doFirst { copy { from jar into stageDir } } push = true } dockerBuilder.dependsOn(bootJar)