Transmode/gradle-docker

springboot2打包后tar包大小是原始包大小的2倍

jinshubao opened this issue · 1 comments

配置:

buildscript {
    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'https://mirrors.huaweicloud.com/repository/maven/' }
        mavenCentral()
    }
    dependencies {
        classpath('se.transmode.gradle:gradle-docker:1.2')
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.1.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'docker'
apply plugin: 'application'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.jean'
version = '0.0.1'
sourceCompatibility = 1.8
targetCompatibility = 1.8
[compileJava, compileTestJava, javadoc]*.options*.encoding = 'UTF-8'


repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    maven { url 'https://mirrors.huaweicloud.com/repository/maven/' }
    mavenCentral()
    maven { url "https://repo.spring.io/milestone" }
}

dependencies {
    implementation('org.springframework.boot:spring-boot-starter-web')
    implementation('org.springframework.boot:spring-boot-starter-actuator')
    implementation('io.micrometer:micrometer-registry-prometheus')
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Greenwich.RC1"
    }
}

mainClassName = 'com.jean.demo.DemoApplication'

docker {
    baseImage = "openjdk:8"
    maintainer = 'user user@126.com'
}

distDocker {
    
    push = false
    exposePort(8080)
    setEnvironment('JAVA_OPTS', '-Xms128m -Xmx256m -Djava.security.egd=file:/dev/./urandom')
    volume("/tmp")
    volume("/logs")
    volume("/config")
}

执行 gradlew disDocker 命令后:

D:\dev\myself\user-service\build\distributions 的目录
2018/12/21  16:16        18,309,120 user-service-0.0.1.tar
 D:\dev\myself\user-service\build\docker 的目录
2018/12/21  16:19               283 Dockerfile
2018/12/21  16:19        36,526,080 user-service-0.0.1.tar

解压distributions的目录的user-service-0.0.1.tar和docker 目录下的user-service-0.0.1.tar对比之后发现:
docker目录下的user-service-0.0.1.tar包含user-service-0.0.1.jar和项目依赖的所有jar文件。
而distributions目录下的user-service-0.0.1.tar只包含一个user-service-0.0.1.jar。

请问下有什么配置或者是方法解决该问题吗?

Please translate this in english if you want it to be looked at.