From 9875384df28db93ec3de85bb5301d6c92d55f9db Mon Sep 17 00:00:00 2001 From: Daniel PETISME Date: Sun, 25 Nov 2018 12:42:29 +0100 Subject: [PATCH] Fix JIB integration www folder issue (#8864) * Fix Jib www for Maven * Fix Jib Doc for Maven * Fix Jib www for Gradle * Use variable + guard --- .../client/templates/angular/webpack/webpack.prod.js.ejs | 2 +- .../client/templates/react/webpack/webpack.prod.js.ejs | 2 +- generators/common/templates/README.md.ejs | 2 +- generators/docker-base.js | 2 +- generators/docker-utils.js | 2 +- generators/server/templates/gradle/docker.gradle.ejs | 9 +++++++++ generators/server/templates/pom.xml.ejs | 2 +- 7 files changed, 15 insertions(+), 6 deletions(-) diff --git a/generators/client/templates/angular/webpack/webpack.prod.js.ejs b/generators/client/templates/angular/webpack/webpack.prod.js.ejs index 6ab3f0963aa9..72aff7d25225 100644 --- a/generators/client/templates/angular/webpack/webpack.prod.js.ejs +++ b/generators/client/templates/angular/webpack/webpack.prod.js.ejs @@ -49,7 +49,7 @@ module.exports = webpackMerge(commonConfig({ env: ENV }), { main: './<%= MAIN_SRC_DIR %>app/app.main' }, output: { - path: utils.root('<%= BUILD_DIR %><% if (buildTool === 'maven') { %>classes/public<% } %><% if (buildTool === 'gradle'){ %>resources/main/public<% } %>'), + path: utils.root('<%= BUILD_DIR %>www'), filename: 'app/[name].[hash].bundle.js', chunkFilename: 'app/[id].[hash].chunk.js' }, diff --git a/generators/client/templates/react/webpack/webpack.prod.js.ejs b/generators/client/templates/react/webpack/webpack.prod.js.ejs index be462e0baf52..8725829e81ba 100644 --- a/generators/client/templates/react/webpack/webpack.prod.js.ejs +++ b/generators/client/templates/react/webpack/webpack.prod.js.ejs @@ -40,7 +40,7 @@ module.exports = webpackMerge(commonConfig({ env: ENV }), { main: './<%= MAIN_SRC_DIR %>app/index' }, output: { - path: utils.root('<%= BUILD_DIR %><% if (buildTool === 'maven') { %>classes/public<% } %><% if (buildTool === 'gradle'){ %>resources/main/public<% } %>'), + path: utils.root('<%= BUILD_DIR %>www'), filename: 'app/[name].[hash].bundle.js', chunkFilename: 'app/[name].[hash].chunk.js' }, diff --git a/generators/common/templates/README.md.ejs b/generators/common/templates/README.md.ejs index ae7882384bb2..30a6eb4c7ce6 100644 --- a/generators/common/templates/README.md.ejs +++ b/generators/common/templates/README.md.ejs @@ -292,7 +292,7 @@ To stop it and remove the container, run: You can also fully dockerize your application and all the services that it depends on. To achieve this, first build a docker image of your app by running: - <% if (buildTool === 'maven') { %>./mvnw package -Pprod jib:dockerBuild<% } %><% if (buildTool === 'gradle') { %>./gradlew bootWar -Pprod jibDockerBuild<% } %> + <% if (buildTool === 'maven') { %>./mvnw package -Pprod verify jib:dockerBuild<% } %><% if (buildTool === 'gradle') { %>./gradlew bootWar -Pprod jibDockerBuild<% } %> Then run: diff --git a/generators/docker-base.js b/generators/docker-base.js index 00691a25e007..b3e8f3662bc6 100644 --- a/generators/docker-base.js +++ b/generators/docker-base.js @@ -46,7 +46,7 @@ function checkImages() { const appConfig = this.appConfigs[index]; if (appConfig.buildTool === 'maven') { imagePath = this.destinationPath(`${this.directoryPath + appsFolder}/target/jib-cache`); - runCommand = './mvnw package -Pprod jib:dockerBuild'; + runCommand = './mvnw package -Pprod verify jib:dockerBuild'; } else { imagePath = this.destinationPath(`${this.directoryPath + appsFolder}/build/jib-cache`); runCommand = './gradlew bootWar -Pprod jibDockerBuild'; diff --git a/generators/docker-utils.js b/generators/docker-utils.js index 6e02b176b170..fc2b6ec36ae6 100644 --- a/generators/docker-utils.js +++ b/generators/docker-utils.js @@ -85,7 +85,7 @@ function checkImageExist(opts = { cwd: './', appConfig: null }) { this.warningMessage = 'To generate the missing Docker image(s), please run:\n'; if (opts.appConfig.buildTool === 'maven') { imagePath = this.destinationPath(`${opts.cwd + opts.cwd}/target/docker`); - this.dockerBuildCommand = './mvnw package -Pprod jib:dockerBuild'; + this.dockerBuildCommand = './mvnw package -Pprod verify jib:dockerBuild'; } else { imagePath = this.destinationPath(`${opts.cwd + opts.cwd}/build/docker`); this.dockerBuildCommand = './gradlew bootWar -Pprod jibDockerBuild'; diff --git a/generators/server/templates/gradle/docker.gradle.ejs b/generators/server/templates/gradle/docker.gradle.ejs index 52bae52b6326..be67c924d00f 100644 --- a/generators/server/templates/gradle/docker.gradle.ejs +++ b/generators/server/templates/gradle/docker.gradle.ejs @@ -45,3 +45,12 @@ jib { useCurrentTimestamp = true } } + +<%_ if (!skipClient) { _%> +task copyWwwIntoStatic (type: Copy) { + from '<%= CLIENT_DIST_DIR %>' + into 'build/resources/main/static' +} + +jibDockerBuild.dependsOn copyWwwIntoStatic +<%_ } _%> diff --git a/generators/server/templates/pom.xml.ejs b/generators/server/templates/pom.xml.ejs index 80fd6b23ded6..a3e15fe3146f 100644 --- a/generators/server/templates/pom.xml.ejs +++ b/generators/server/templates/pom.xml.ejs @@ -1075,7 +1075,7 @@ - docker-resources + jib-www-resources verify copy-resources