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') } bootJar { enabled = true } jar { enabled = false } docker{ baseImage 'openjdk:8-jre-alpine' maintainer 'tina 976056042@qq.com' registry 'registry.cn-hangzhou.aliyuncs.com' } task dockerBuilder(type: Docker) { registry='registry.cn-hangzhou.aliyuncs.com/tuon' applicationName = 'eureka_config' tagVersion = jar.version setEnvironment('JAVA_OPTS', '-Xms256m -Xmx512m') addFile("./${jar.baseName}-${jar.version}.jar","app.jar") addFile("*.yml","/config/") addFile('./docker-entrypoint.sh','/usr/local/bin/') runCommand("chmod +x /usr/local/bin/docker-entrypoint.sh") runCommand("ln -s /usr/local/bin/docker-entrypoint.sh /entrypoint.sh") exposePort(12121) entryPoint(["docker-entrypoint.sh"]) doFirst { copy { from jar into stageDir } copy { from "${buildDir}/resources/main" include "*.*" into stageDir } } push = false } dockerBuilder.dependsOn(bootJar)