[英]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.