简体   繁体   中英

Prevent build attempt when deploying single jar on Google App Engine with java11

I have a spring java project which is built on a CI system outside of google cloud. The final build command is gradle bootJar . I want to deploy the resulting jar to Google App Engine.

The suggested way to do so is just calling gcloud app deploy my.jar . Unfortunately, this approach doesn't work for me as the application needs more RAM than provided by the default instance type (F1 = 256MB). So I have to specify the instance type somehow.

My current approach is to create a custom app.yaml - and also a .gcloudignore to ensure that only the jar is uploaded. My app.yaml looks like this:

runtime: java11
instance_class: F2
entrypoint: java -noverify -jar my.jar

While the instance is working, the instance logs indicate that a build is tried in parallel (log excerpt):

Starting Step #5 - "builder"
Step #5 - "builder": Already have image (with digest): eu.gcr.io/gae-runtimes/buildpacks/java11/builder:java11_20200913_11_0_RC00
Step #5 - "builder": === Java - App Engine (google.java.appengine@0.9.0) ===
Step #5 - "builder": DEBUG: Using GOOGLE_RUNTIME: java11
Step #5 - "builder": DEBUG: Using config appengine.Config{Runtime:"java11", Entrypoint:appengine.Entrypoint{Type:"User", Command:"java -noverify -jar my.jar", WorkDir:""}, MainExecutable:""}
Step #5 - "builder": === Utils - Label Image (google.utils.label@0.0.1) ===
Finished Step #5 - "builder"

These build attempts do not happen when I specify the jar directly in gcloud app deploy , but as said this fails due to memory.

Ideally, I want to use my own app.yaml in order to specify other configuration options as well. But I don't want to have a build happening all the time.

So is there a way to either suppress these build attempts or, alternatively, pass additional configuration options which would usually be in an app.yaml to a gcloud app deploy my.jar call?

What you are trying to do is not possible, if you use a app.yaml to deploy your app a build will always be triggered and if you use gradle you will not be able to select the instance_class like the app.yaml allows you to do. So there is no optimal solution for your problem, However there is an alternative for this, which is to use App Engine Flex to deploy a container with your my.jar file.

You can check this link for how to create a docker file to run a .jar app. Also in this documentation you can see how you can deploy that docker containing your jar file to App Engine Flex, this configuration will also create an app.yaml file and in that app.yaml you can specify the infrastructure that you will need to run your app. As you can see in this second documentation , you could add the following block of configurations to the app.yaml to let App Engine Flex know how much infrastructure you need for your app's container:

resources:
  cpu: 2
  memory_gb: 2.3
  disk_size_gb: 10
  volumes:
  - name: ramdisk1
    volume_type: tmpfs
    size_gb: 0.5

NOTE : Since you already have your app up and running in an instance of App Engine Standard I would say that the proposed alternative is not worth the effort if you can simply ignore the build logs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM