Building with Docker results in running a dev and prod build for the frontend
mraible opened this issue · comments
Overview of the issue
When running this command:
./mvnw package -Pprod verify jib:dockerBuild
The frontend builds for both dev and prod profiles.
[INFO] --- frontend-maven-plugin:1.10.0:npm (webpack build dev) @ space ---
[INFO] npm not inheriting proxy config from Maven
[INFO] Running 'npm run webpack:build' in /Users/mraible/spacefan2
[INFO]
[INFO] > space@0.0.1-SNAPSHOT webpack:build /Users/mraible/spacefan2
[INFO] > npm run cleanup && npm run webpack:build:main
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT cleanup /Users/mraible/spacefan2
[INFO] > rimraf target/classes/static/
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT webpack:build:main /Users/mraible/spacefan2
[INFO] > npm run webpack -- --config webpack/webpack.dev.js --env.stats=minimal
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT webpack /Users/mraible/spacefan2
[INFO] > node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.dev.js" "--env.stats=minimal"
[INFO]
Webpack: Starting ...
[INFO]
[INFO] ✔ Compile modules
[INFO] ✔ Build modules
[INFO] ✔ Optimize modules
[INFO] ✔ Emit files
[INFO]
[INFO] Webpack: Finished after 16.523 seconds.
[INFO]
[INFO] DONE Compiled successfully in 16530ms1:16:30 PM
[INFO]
[INFO] 452 modules
[INFO]
[INFO] --- frontend-maven-plugin:1.10.0:npm (webpack build prod) @ space ---
[INFO] npm not inheriting proxy config from Maven
[INFO] Running 'npm run webpack:prod' in /Users/mraible/spacefan2
[INFO]
[INFO] > space@0.0.1-SNAPSHOT webpack:prod /Users/mraible/spacefan2
[INFO] > npm run cleanup && npm run webpack:prod:main && npm run clean-www
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT cleanup /Users/mraible/spacefan2
[INFO] > rimraf target/classes/static/
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT webpack:prod:main /Users/mraible/spacefan2
[INFO] > npm run webpack -- --config webpack/webpack.prod.js --profile
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT webpack /Users/mraible/spacefan2
[INFO] > node --max_old_space_size=4096 node_modules/webpack/bin/webpack.js "--config" "webpack/webpack.prod.js" "--profile"
[INFO]
[INFO] Webpack Bundle Analyzer saved report to /Users/mraible/spacefan2/target/classes/stats.html
[INFO] Hash: 7835d37ac50d2a63e2be
[INFO] Version: webpack 4.43.0
[INFO] Time: 28252ms
[INFO] Built at: 08/11/2020 1:17:02 PM
[INFO] Asset Size Chunks Chunk Names
[INFO] ./i18n/en.json 12.6 KiB [emitted]
[INFO] ./i18n/fr.json 13.8 KiB [emitted]
[INFO] app/0.7835d37ac50d2a63e2be.chunk.js 19.8 KiB 0 [emitted] [immutable]
[INFO] app/1.7835d37ac50d2a63e2be.chunk.js 33.8 KiB 1 [emitted] [immutable]
[INFO] app/2.7835d37ac50d2a63e2be.chunk.js 9.67 KiB 2 [emitted] [immutable]
[INFO] app/3.7835d37ac50d2a63e2be.chunk.js 869 bytes 3 [emitted] [immutable]
[INFO] app/4.7835d37ac50d2a63e2be.chunk.js 3.03 KiB 4 [emitted] [immutable]
[INFO] app/5.7835d37ac50d2a63e2be.chunk.js 803 bytes 5 [emitted] [immutable]
[INFO] app/6.7835d37ac50d2a63e2be.chunk.js 7.25 KiB 6 [emitted] [immutable]
[INFO] app/7.7835d37ac50d2a63e2be.chunk.js 4.98 KiB 7 [emitted] [immutable]
[INFO] app/8.7835d37ac50d2a63e2be.chunk.js 5.28 KiB 8 [emitted] [immutable]
[INFO] app/global.7835d37ac50d2a63e2be.bundle.js 936 bytes 9 [emitted] [immutable] global
[INFO] app/main.7835d37ac50d2a63e2be.bundle.js 955 KiB 10 [emitted] [immutable] [big] main
[INFO] app/main.7835d37ac50d2a63e2be.bundle.js.LICENSE.txt 685 bytes [emitted]
[INFO] content/cdbbebca5239dfc7bd08d89d2523696a.svg 249 KiB [emitted] [big]
[INFO] content/cfd81fbabebba3d187b7f0243b971186.png 605 bytes [emitted]
[INFO] content/css/loading.css 2.72 KiB [emitted]
[INFO] content/global.c5875b4a3bbc1ca82290.css 1.51 KiB 9 [emitted] [immutable] global
[INFO] content/images/jhipster_family_member_0.svg 11.9 KiB [emitted]
[INFO] content/images/jhipster_family_member_0_head-192.png 13.1 KiB [emitted]
[INFO] content/images/jhipster_family_member_0_head-256.png 6.87 KiB [emitted]
[INFO] content/images/jhipster_family_member_0_head-384.png 10.1 KiB [emitted]
[INFO] content/images/jhipster_family_member_0_head-512.png 11.2 KiB [emitted]
[INFO] content/images/jhipster_family_member_1.svg 222 KiB [emitted]
[INFO] content/images/jhipster_family_member_1_head-192.png 6.88 KiB [emitted]
[INFO] content/images/jhipster_family_member_1_head-256.png 9.28 KiB [emitted]
[INFO] content/images/jhipster_family_member_1_head-384.png 14.7 KiB [emitted]
[INFO] content/images/jhipster_family_member_1_head-512.png 16.1 KiB [emitted]
[INFO] content/images/jhipster_family_member_2.svg 22.1 KiB [emitted]
[INFO] content/images/jhipster_family_member_2_head-192.png 5.3 KiB [emitted]
[INFO] content/images/jhipster_family_member_2_head-256.png 6.53 KiB [emitted]
[INFO] content/images/jhipster_family_member_2_head-384.png 9.46 KiB [emitted]
[INFO] content/images/jhipster_family_member_2_head-512.png 10.3 KiB [emitted]
[INFO] content/images/jhipster_family_member_3.svg 18.7 KiB [emitted]
[INFO] content/images/jhipster_family_member_3_head-192.png 6 KiB [emitted]
[INFO] content/images/jhipster_family_member_3_head-256.png 7.84 KiB [emitted]
[INFO] content/images/jhipster_family_member_3_head-384.png 11.7 KiB [emitted]
[INFO] content/images/jhipster_family_member_3_head-512.png 13.2 KiB [emitted]
[INFO] content/images/jhipster_family_member_4.svg 249 KiB [emitted] [big]
[INFO] content/images/jhipster_family_member_4_head-192.png 6.43 KiB [emitted]
[INFO] content/images/jhipster_family_member_4_head-256.png 8.43 KiB [emitted]
[INFO] content/images/jhipster_family_member_4_head-384.png 12.6 KiB [emitted]
[INFO] content/images/jhipster_family_member_4_head-512.png 16.3 KiB [emitted]
[INFO] content/images/logo-jhipster.png 605 bytes [emitted]
[INFO] content/main.8fa0acb269eccc1271c2.css 142 KiB 10 [emitted] [immutable] main
[INFO] content/scss/_bootstrap-variables.scss 1.08 KiB [emitted]
[INFO] content/scss/global.scss 3.72 KiB [emitted]
[INFO] content/scss/vendor.scss 388 bytes [emitted]
[INFO] favicon.ico 1.54 KiB [emitted]
[INFO] index.html 3.95 KiB [emitted]
[INFO] manifest.webapp 745 bytes [emitted]
[INFO] robots.txt 168 bytes [emitted]
[INFO] service-worker.js 5.58 KiB [emitted]
[INFO] swagger-ui/absolute-path.js 530 bytes [emitted]
[INFO] swagger-ui/axios.min.js 13.4 KiB [emitted]
[INFO] swagger-ui/dist/images/throbber.gif 9.04 KiB [emitted]
[INFO] swagger-ui/favicon-16x16.png 665 bytes [emitted]
[INFO] swagger-ui/favicon-32x32.png 628 bytes [emitted]
[INFO] swagger-ui/index.html 2.13 KiB [emitted]
[INFO] swagger-ui/index.js 813 bytes [emitted]
[INFO] swagger-ui/oauth2-redirect.html 2.37 KiB [emitted]
[INFO] swagger-ui/swagger-ui-bundle.js 952 KiB [emitted] [big]
[INFO] swagger-ui/swagger-ui-standalone-preset.js 300 KiB [emitted] [big]
[INFO] swagger-ui/swagger-ui.css 138 KiB [emitted]
[INFO] swagger-ui/swagger-ui.js 354 KiB [emitted] [big]
[INFO] workbox-468c4d03.js 7.7 KiB [emitted]
[INFO] Entrypoint global = content/global.c5875b4a3bbc1ca82290.css app/global.7835d37ac50d2a63e2be.bundle.js
[INFO] Entrypoint main [big] = content/main.8fa0acb269eccc1271c2.css app/main.7835d37ac50d2a63e2be.bundle.js
[INFO] [3] ./node_modules/ng-jhipster/__ivy_ngcc__/fesm2015/ng-jhipster.js + 1 modules 208 KiB {10} [built]
[INFO] | 2 modules
[INFO] [4] ./node_modules/@angular/router/__ivy_ngcc__/fesm2015/router.js + 9 modules 223 KiB {10} [built]
[INFO] | 10 modules
[INFO] [7] ./node_modules/@ngx-translate/core/__ivy_ngcc__/fesm2015/ngx-translate-core.js + 1 modules 57.1 KiB {10} [built]
[INFO] | 2 modules
[INFO] [9] ./node_modules/@ng-bootstrap/ng-bootstrap/__ivy_ngcc__/fesm2015/ng-bootstrap.js + 7 modules 529 KiB {10} [built]
[INFO] | 8 modules
[INFO] [14] ./src/main/webapp/app/core/auth/account.service.ts 3.87 KiB {10} [built]
[INFO] [] 11859ms -> [] 865ms -> [] 1225ms -> factory:935ms building:13ms dependencies:986ms = 15883ms
[INFO] [17] ./src/main/webapp/app/app.constants.ts 517 bytes {10} [built]
[INFO] [] 11859ms -> [] 865ms -> factory:778ms building:3ms = 13505ms
[INFO] [18] ./src/main/webapp/app/core/login/login.service.ts + 1 modules 2.13 KiB {10} [built]
[INFO] | ./src/main/webapp/app/core/login/login.service.ts 1.23 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> [] 1225ms -> factory:1134ms building:42ms dependencies:1004ms = 16129ms
[INFO] | ./src/main/webapp/app/core/auth/auth-session.service.ts 896 bytes [built]
[INFO] | [] 11859ms -> [] 865ms -> [] 1225ms -> [] 1176ms -> factory:899ms building:1ms dependencies:0ms = 16025ms
[INFO] [36] ./src/main/webapp/app/shared/shared.module.ts + 1 modules 3.36 KiB {10} [built]
[INFO] | ./src/main/webapp/app/shared/shared.module.ts 1.55 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/shared/shared-libs.module.ts 1.75 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> [] 1225ms -> factory:662ms building:3ms dependencies:861ms = 15475ms
[INFO] [44] ./src/main/webapp/app/shared/language/find-language-from-key.pipe.ts 754 bytes {10} [built]
[INFO] [] 11859ms -> [] 865ms -> [] 1225ms -> factory:1134ms building:42ms dependencies:1004ms = 16129ms
[INFO] [45] ./src/main/webapp/app/shared/auth/has-any-authority.directive.ts 2.35 KiB {10} [built]
[INFO] [] 11859ms -> [] 865ms -> [] 1225ms -> factory:1134ms building:42ms dependencies:1004ms = 16129ms
[INFO] [48] (webpack)/buildin/global.js 472 bytes {10} [built]
[INFO] [] 11859ms -> [] 865ms -> [80] 940ms -> factory:1020ms building:1ms = 14685ms
[INFO] [54] ./src/main/webapp/app/shared/alert/alert-error.component.ts 7.92 KiB {10} [built]
[INFO] [] 11859ms -> [] 865ms -> [] 1225ms -> factory:662ms building:3ms dependencies:861ms = 15475ms
[INFO] [79] ./src/main/webapp/content/scss/global.scss 39 bytes {9} [built]
[INFO] factory:328ms building:8354ms = 8682ms
[INFO] [82] ./src/main/webapp/manifest.webapp 59 bytes {10} [built]
[INFO] [] 11859ms -> [] 865ms -> factory:939ms building:1ms dependencies:386ms = 14050ms
[INFO] [89] ./src/main/webapp/app/app.main.ts + 26 modules 80.9 KiB {10} [built]
[INFO] | ./src/main/webapp/app/app.main.ts 519 bytes [built]
[INFO] | factory:477ms building:11382ms = 11859ms
[INFO] | ./src/main/webapp/app/polyfills.ts 92 bytes [built]
[INFO] | [] 11859ms -> factory:847ms building:18ms dependencies:850ms = 13574ms
[INFO] | ./src/main/webapp/app/blocks/config/prod.config.ts 265 bytes [built]
[INFO] | [] 11859ms -> factory:847ms building:18ms dependencies:850ms = 13574ms
[INFO] | ./src/main/webapp/app/app.module.ts 2.64 KiB [built]
[INFO] | [] 11859ms -> factory:847ms building:18ms dependencies:850ms = 13574ms
[INFO] | ./src/main/webapp/app/vendor.ts 97 bytes [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/core/core.module.ts 5.92 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/layouts/error/error.component.ts 3.57 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/layouts/navbar/active-menu.directive.ts 1.62 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/layouts/navbar/navbar.component.ts 28.3 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/app-routing.module.ts 2.27 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/home/home.module.ts 1.09 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/entities/entity.module.ts 1.7 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/layouts/profiles/page-ribbon.component.ts 2.74 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/layouts/footer/footer.component.ts 1.07 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | ./src/main/webapp/app/layouts/main/main.component.ts 3.93 KiB [built]
[INFO] | [] 11859ms -> [] 865ms -> factory:850ms building:375ms dependencies:1153ms = 15102ms
[INFO] | + 12 hidden modules
[INFO] + 199 hidden modules
[INFO]
[INFO] WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).
[INFO] This can impact web performance.
[INFO] Assets:
[INFO] swagger-ui/swagger-ui-bundle.js (952 KiB)
[INFO] swagger-ui/swagger-ui-standalone-preset.js (300 KiB)
[INFO] swagger-ui/swagger-ui.js (354 KiB)
[INFO] content/images/jhipster_family_member_4.svg (249 KiB)
[INFO] content/cdbbebca5239dfc7bd08d89d2523696a.svg (249 KiB)
[INFO] app/main.7835d37ac50d2a63e2be.bundle.js (955 KiB)
[INFO]
[INFO] WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance.
[INFO] Entrypoints:
[INFO] main (1.07 MiB)
[INFO] content/main.8fa0acb269eccc1271c2.css
[INFO] app/main.7835d37ac50d2a63e2be.bundle.js
[INFO]
[INFO]
[INFO] > space@0.0.1-SNAPSHOT clean-www /Users/mraible/spacefan2
[INFO] > rimraf target/classes/static/app/{src,target/}
Reproduce the error
Create a new app and build a Docker image for it.
Suggest a Fix
Only build for prod since -Pprod
is passed in.
JHipster Version(s)
space@0.0.1-SNAPSHOT /Users/mraible/spacefan2
├── generator-jhipster@6.10.1
└─┬ generator-jhipster-micronaut@0.3.7
└── generator-jhipster@6.10.1 deduped
JHipster configuration, a .yo-rc.json
file generated in the root folder
.yo-rc.json file
{ "generator-jhipster": { "authenticationType": "oauth2", "cacheProvider": "ehcache", "clientFramework": "angularX", "serverPort": "8080", "serviceDiscoveryType": false, "skipUserManagement": true, "baseName": "space", "buildTool": "maven", "databaseType": "sql", "devDatabaseType": "h2Disk", "enableHibernateCache": true, "enableSwaggerCodegen": false, "enableTranslation": true, "jhiPrefix": "jhi", "languages": ["en", "fr"], "messageBroker": false, "nativeLanguage": "en", "prodDatabaseType": "postgresql", "searchEngine": false, "skipClient": false, "testFrameworks": ["protractor"], "websocket": false, "applicationType": "monolith", "packageName": "org.jhipster.space", "packageFolder": "org/jhipster/space", "jhipsterVersion": "6.10.1", "creationTimestamp": 1597071660768, "skipServer": false, "clientPackageManager": "npm", "clientTheme": "none", "clientThemeVariant": "", "useSass": true, "embeddableLaunchScript": false, "entitySuffix": "", "dtoSuffix": "DTO", "otherModules": [ { "name": "generator-jhipster-micronaut", "version": "0.3.7" } ], "blueprints": [ { "name": "generator-jhipster-micronaut", "version": "0.3.7" } ], "herokuAppName": "micronaut-space", "herokuDeployType": "git", "herokuJavaVersion": "11", "useOkta": true, "oktaAdminLogin": "mraible@gmail.com", "oktaAdminPassword": "Password1" }, "entities": ["SpaceEvent", "Mission"] }
JDL for the Entity configuration(s) entityName.json
files generated in the .jhipster
directory
JDL entity definitions
entity SpaceEvent { name String required, date LocalDate required, description TextBlob required, photo ImageBlob required, type SpaceEventType required } entity Mission { name String required, description String } enum SpaceEventType { LAUNCH, LANDING } relationship OneToOne { SpaceEvent{mission(name)} to Mission } paginate SpaceEvent with infinite-scroll paginate Mission with pagination
Environment and Tools
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)
git version 2.24.3 (Apple Git-128)
node: v14.7.0
npm: 6.14.7
yeoman: 3.1.1
Docker version 19.03.12, build 48a66213fe
docker-compose version 1.26.2, build eefe0d31
Can it be that the webpack build in dev mode comes from run webpack:test
which is done in prod profile? Not tried it yet though
It seems to be the activation of the webpack profile.
Main generator
<id>webpack</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
micronaut
<id>webpack</id>
<activation>
<file>
<missing>${basedir}/target/classes/static/app/main.bundle.js</missing>
</file>
</activation>
I remember some issues with that, maybe it was exactly the problem with multiple builds. Replacing it with the activation from 6.x main generator works fine, but it seems prod build is executed two times. First for unit tests, second for integration tests.
I can see two times even java compile, not sure why. This also seem to create two shaded jars, which of course generates two times resources, which result in two webpack builds eventually.
@mraible Can you try leaving out package
(or only verify
?) and setting the activation? At least it just executed the whole build once.
@atomfrede Leaving out package
does seem to solve the problem. We should document this since it's different from the regular generator. Or maybe we don't need to specify package
for the main generator?
Nevermind, I tried again and it still happens.
$ ./mvnw -Pprod verify jib:dockerBuild
...
[INFO] --- frontend-maven-plugin:1.10.0:npm (npm install) @ space ---
...
[INFO] --- frontend-maven-plugin:1.10.0:npm (webpack build dev) @ space ---
...
[INFO] --- frontend-maven-plugin:1.10.0:npm (webpack build prod) @ space ---
Did you change the activation part? I will check and provide a PR as webpack(dev) will be active even when doing -Pprod
on a clean project as the develop app bundle is not there yet.
EDIT: The generated readme seems already to be up to date: ./mvnw -Pprod verify jib:dockerBuild
I did not change anything in pom.xml
, I just tried running it without package
. You can try cloning my project if you want to try it there.
git clone git@github.com:oktadeveloper/okta-jhipster-micronaut-example.git
With the activation not checking the development bundle I have
$ ./mvnw -Pprod verify jib:dockerBuild
...
[INFO] --- frontend-maven-plugin:1.10.0:install-node-and-npm (install node and npm) @ mhipster-docker ---
...
[INFO] --- frontend-maven-plugin:1.10.0:npm (npm install) @ mhipster-docker ---
...
[INFO] --- frontend-maven-plugin:1.10.0:npm (webpack build prod) @ mhipster-docker ---
...
[INFO] --- frontend-maven-plugin:1.10.0:npm (webpack build test) @ mhipster-docker ---
See #159