-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App Engine Java 11 generator to create thin JARs #10362
Comments
@saturnism : Thanks for creating the issue. Feel free to assign it to me as well. I'll start this once we finalize the java 11 gae enhancements. |
@ludoch @saturnism : I was trying this out by constructing the thin jar using spring-boot-thin-launcher which I believe is the standard approach of doing this (let me know if you have an alternative suggestion). Although the thin jar construction seems to work in my local after deploying it to Google App Engine I get;
I think this is due to the thin-launcher tries to grab some dependencies at runtime and app engine file-system is read-only. I am thinking of a way to overcome this. Let me know if you guys have any examples or deployments of using thin jars in app engine with Java 11 or is there other library that is being used to create the thin jars for app engine? I couldn't find much documentation on this except for few lines mentioned at https://cloud.google.com/appengine/docs/standard/java11/runtime#application_startup. On the plus side it does seems to significantly improve the deployment time (size of jar seems significantly reduced). 😄 |
I've created a PR. This adds support for "unjaring" the jar file within the staging directory as ludoch suggested. However I found no information of this process in google documentation; so it was a lot of trial and error. The only piece of documentation I found is; https://cloud.google.com/appengine/docs/standard/java11/runtime#application_startup There it says and I quote;
However I couldn't get this approach to work; the problem is that creating a standard thin jar with the spring-bot-thin-launcher for example doesn't work since it tries to download the dependencies at startup and appengine doesn't allow writing to the disk. I wonder whether the documentation here is wrong (maybe AppEngine Java 11 still in Beta?). Anyways, therefore this approach just extracts the content of the fatjar within the staging folder, and it seems to work; I've tested it on an actual deployment. However when running appengine:deploy (or in the case of gradle appengineDeploy) it does the staging again. I mean as far as I know there's no way to do the deployment only and therefore I didn't find a easy method of removing the jar file from the staging folder. If you guys have any suggestions about this let me know. Otherwise I think we have to just keep the jar file within the staging folder? Also I've uncovered some other issues with the GAE sub-generator (particularly on the Gradle side); I'll create some more issues in the future. 😄 cc: @saturnism @ludoch |
I don't think this is any way close to being standard. |
@chanseokoh : Thanks for your input; could you please elaborate what it is when it comes to deploying spring boot applications in GAE? As per the following documents it says it can support thin jars but doesn't say exactly which method to use (maybe I missed it, correct me if I am wrong); https://cloud.google.com/appengine/docs/standard/java11/runtime#application_startup EDIT: I see you've commented in the GoogleCloudPlatform/app-maven-plugin#399; any further correspondence will be there. Thanks a bunch again 😄 |
As per my discussion in GoogleCloudPlatform/app-maven-plugin#399 we need to change this approach. I will refactor the current pull request soon. 😄 |
You could read https://github.com/ludoch/samples/blob/f4fcfb6ea1c7bc5bc37c36307e1c91a38f2445ff/java11/springboot/pom.xml |
@ludoch : My discussion in the other thread; specifically the following comment; GoogleCloudPlatform/app-maven-plugin#399 (comment) will enable to not use the fat jar approach at all I believe (and would not need the hack). Let me know if you agree. 😄 |
@ludoch : Sorry, I misunderstood you there; yes hack is still needed to remove the fatjar. 👍 And thanks much 🥇 |
I've made some changes to the pull request with ludoch's workaround for removing the original jar and I think we are good to go with this. 😄 |
@deepu105 : Thanks for assigning a bug bounty for this; although not strictly necessary as I enjoyed doing it. I am getting a lot of coffees and teas for myself these days thanks to the extra pocket money. 🍵 🍵 |
* add support for thin jar in gae Only adds to maven build; work in progress * correcting mistake introduced in a pervious pull request A previous pull request incorrectly removes the com.google.cloud.tools when gaeCloudSQLInstanceNeeded is set to false #10362 * add correct handlers for retrieving static files * remove bootWar from gradle The new GAE with Java 11 builds on JAR; this has been done on the maven side. * correcting mistake introduced in a pervious pull request A previous pull request incorrectly removes the com.google.cloud.tools when gaeCloudSQLInstanceNeeded is set to false * replace deprecated value "project" by "projectId" * testing with cloudsql; change string to single quotes If this is not done the following error is created; yntaxError: Multi-line double-quoted string needs to be sufficiently indented (16:14) 14 | datasource: 15 | type: com.zaxxer.hikari.HikariDataSource > 16 | url: "jdbc:mysql://google/mysql?cloudSqlInstance=abstract-block-253023:us-central1:testjhipster | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Add copyright information * add mainclass name instead of basename * add gradle support for unjaring the original jar This adds Gradle side support for thin jars * missing symbol from previous commit * remove the original jar as per discussion * minor bug fix per code review * add max heap size to entrypoint field in app.yaml * Revert Xmx change * correction of the url strings * remove whitespaces in project ID * simplify the prod-gae profile definition * thin jar generation support for maven * thin jar generation support for gradle * adjustments to the maven and gradle deployment commands * add thinResolve step before staging * prettier issue fix * add error code checking for gcloud - gcloud seems to print out info messages to the error stream as well. We need to check whether it's an actual error * add trim to remove unnecessary newline and remove silent mode for prompt in order to trigger cloud sql api * fix the trim line more elegantly * add missing maven dependency * refactor code to include application-prod-gae.yml file regardless of Cloud SQL - this makes sure the correct port environment variable is passed whether the user chose to use cloud sql or not. * fix dependency problem (similar to #9175) to get rid of the clean option * add dependency before the check for cloud sql * changed per code review
Overview of the feature request
from @ludoch #10331 (comment)
Motivation for or Use Case
To allow JHipster on App Engine Java 11 to take advantage of static file serving.
Related issues or PR
#10331
The text was updated successfully, but these errors were encountered: