Issue:
Gradle with docker is corrupting the war file during the copy from lib to docker folder
4.8.1
Fix:
docker.gradle in copy function:
Gradle copy of war file runs a filter to replace project name placeholder with real project name.
The filter operation has to run only on Docker file. When it runs on the binary war file it corrupts it.
[email protected] /media/spyder/data/projects/MicroService/AiHelloGateway
└── [email protected]
##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.aihello",
"nativeLanguage": "en",
"microservicePath": "../AiHelloMicroService"
},
"jhipsterVersion": "4.8.1",
"baseName": "AiHelloGateway",
"packageName": "com.aihello",
"packageFolder": "com/aihello",
"serverPort": "8080",
"authenticationType": "uaa",
"uaaBaseName": "AiHelloUaa",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": "kafka",
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSocialSignIn": false,
"clientFramework": "angular1",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "gateway",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en"
]
}
}
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
git version 2.14.1
node: v7.9.0
npm: 4.2.0
bower: 1.8.0
gulp:
[15:28:39] CLI version 1.3.0
[15:28:39] Local version 3.9.1
yeoman: 2.0.0
yarn: 0.22.0
Docker version 17.06.0-ce, build 02c1d87
docker-compose version 1.13.0, build 1719ceb
OS: Linux spyderXPS 4.13.0-041300rc7-generic #201708272131 SMP Mon Aug 28 01:32:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Good catch, will take care of it, but of course if you have a solution feel free to create a PR.
How is it corrupted ?
Can you post your logs ? Compare war size etc ?
I fixed the problem in my jhipster by fixing this function
task copyDockerFiles(type: Copy) {
description = "Copy Dockerfile and required data to build directory"
from 'src/main/docker'
from "${project.buildDir}/libs"
into { "${project.buildDir}/docker" }
include "*"
exclude "**/*.yml"
filter {
it.replace('@project.build.finalName@', rootProject.name + '-' + version)
}
}
Here filter should have exclusive block for war and DockerFile with filter only in DockerFile.
I hardcoded the warfile name and removed the filter to fix this issue.
We can selectively apply the filter pattern via filesMatching in the copy spec. Doing a filter on a binary file usually doesn't work.
EDIT: Or we use just to from blocks and only the block that copies src/main/docker is filtered. Will provide a fix later today. Something like this should work
task copyDockerFiles(type: Copy) {
description = "Copy Dockerfile and required data to build directory"
from('src/main/docker') {
include '*'
exclude "**/*.yml"
filter {
it.replace('@project.build.finalName@', rootProject.name + '-' + version)
}
}
from "${project.buildDir}/libs"
into { "${project.buildDir}/docker" }
}
Thank you @ganeshkrishnan1 for the report. Indeed this looks broken to me
@atomfrede's solution looks good.
This looks important to me -> @atomfrede I can do a specific patch release tomorrow, would that be good for you?
Yes, that is fine.
Most helpful comment
We can selectively apply the filter pattern via
filesMatchingin the copy spec. Doing afilteron a binary file usually doesn't work.EDIT: Or we use just to
fromblocks and only the block that copiessrc/main/dockeris filtered. Will provide a fix later today. Something like this should work