简体   繁体   English

使用 java11 在 Google App Engine 上部署单个 jar 时防止构建尝试

[英]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.我有一个 spring java 项目,它建立在谷歌云之外的 CI 系统上。 The final build command is gradle bootJar .最后的构建命令是gradle bootJar I want to deploy the resulting jar to Google App Engine.我想将生成的 jar 部署到 Google App Engine。

The suggested way to do so is just calling gcloud app deploy my.jar .建议的方法是调用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).不幸的是,这种方法对我不起作用,因为应用程序需要的 RAM 比默认实例类型 (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.我目前的方法是创建一个自定义app.yaml - 以及一个.gcloudignore以确保只上传 jar。 My app.yaml looks like this:我的app.yaml看起来像这样:

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.当我直接在gcloud app deploy指定 jar 时,这些构建尝试不会发生,但gcloud app deploy这由于内存而失败。

Ideally, I want to use my own app.yaml in order to specify other configuration options as well.理想情况下,我想使用我自己的 app.yaml 来指定其他配置选项。 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?那么有没有办法抑制这些构建尝试,或者将通常位于app.yaml中的其他配置选项传递给gcloud app deploy my.jar调用?

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.您尝试做的事情是不可能的,如果您使用app.yaml来部署您的应用程序,则始终会触发构建,如果您使用gradle您将无法像app.yaml允许您那样选择instance_class . 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.因此,您的问题没有最佳解决方案,但是有一个替代方案,即使用 App Engine Flex 使用my.jar文件部署容器。

You can check this link for how to create a docker file to run a .jar app.您可以查看此链接以了解如何创建 docker 文件以运行.jar应用程序。 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.此外,在本文档中,您可以看到如何将包含 jar 文件的 docker 部署到 App Engine Flex,此配置还将创建一个app.yaml文件,在该app.yaml中,您可以指定运行您的应用程序所需的基础架构应用程序。 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:正如您在第二个文档中所见,您可以将以下配置块添加到app.yaml ,让 App Engine Flex 知道您的应用程序容器需​​要多少基础设施:

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.注意:由于您的应用程序已经在 App Engine 标准实例中启动并运行,因此如果您可以简单地忽略构建日志,那么建议的替代方案不值得付出努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 java11 在谷歌云上使用 mysql 部署 Spring 启动应用程序 - Deploying a Spring boot application with mysql on google cloud with java11 将 Google App Engine 应用程序部署为单个 JAR 时如何指定实例类? - How to specify an instance class when deploying a Google App Engine application as a single JAR? 将 Mockito 与 Java11 一起使用时的异常 - Exception when using Mockito with Java11 通过使用特定的jar来创建Java类来在Google App Engine中部署War文件 - Deploying war file in google app engine by creating a java class using the jar specific to deploy it 将Java Web Project部署到Google App Engine - Deploying Java Web Project to Google App Engine 迁移到Java11 - Migrate to java11 Java Spring REST API on GCP standard java11 app engine: Successful appengine:deploy but endpoint/route hangs indefinitely - Java Spring REST API on GCP standard java11 app engine: Successful appengine:deploy but endpoint/route hangs indefinitely Java-11 spring-boot 部署到谷歌云错误:应用程序不满足 [java11] 的要求 - Java-11 spring-boot deployment to google cloud error: app does not satisfy requirements for [java11] 部署到Google App Engine时的运行时异常 - Runtime exception when deploying to Google App Engine java11 允许在一行中编译和执行 - java11 allows the compilation and execution in a single line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM