首页 > 解决方案 > 无法在应用引擎标准环境 (GCP) 中部署预构建映像

问题描述

我的 Spring Boot 应用程序在云构建和部署中运行良好,直到 9 月没有任何问题。现在我的触发器在 gcloud app deploy 中失败了。

第 4 步:错误:(gcloud.app.deploy)INVALID_ARGUMENT:部署不能使用预构建的映像。仅在 App Engine 柔性环境中允许使用预构建的图像。

应用程序.yaml

runtime: java11
env: standard
service: service
handlers:
  - url: /.*
    script: this field is required, but ignored

cloudbuild.yaml

steps:
# backend deployment
# Step 1:
  - name: maven:3-jdk-14
    entrypoint: mvn
    dir: 'service'
    args: ["test"]

# Step 2:
  - name: maven:3-jdk-14
    entrypoint: mvn
    dir: 'service'
    args: ["clean", "install", "-Dmaven.test.skip=true"]

# Step 3:
  - name: docker
    dir: 'service'
    args: ["build", "-t", "gcr.io/service-base/base", "."]

# Step 4:
  - name: "gcr.io/cloud-builders/docker"
    args: ["push", "gcr.io/service-base/base"]

# Step 5:
  - name: 'gcr.io/cloud-builders/gcloud'
    dir: 'service/src/main/appengine'
    args: ['app', 'deploy', "--image-url=gcr.io/service-base/base"]
    timeout: "30m0s"
# Step 6:
  # dispatch.yaml deployment
  - name: "gcr.io/cloud-builders/gcloud"
    dir: 'service/src/main/appengine'
    args: ["app", "deploy", "dispatch.yaml"]
    timeout: "30m0s"
timeout: "100m0s"
images: ["gcr.io/service-base/base"]

云构建错误

提前致谢。我很困惑我的构建之前是如何工作的以及我现在做错了什么。

标签: spring-bootgoogle-app-enginegoogle-cloud-platformgcloud

解决方案


您不能在 App Engine 标准上部署自定义容器。您必须提供您的代码和环境运行时。然后Buildpack用于在 Google 端创建一个标准容器(作为参考,为此运行了一个新的 Cloud Build 作业)并部署在 App Engine 上。

我建议您查看 Cloud Run 以使用您的自定义容器。它非常接近 App Engine(在许多方面甚至更好!)并且非常可定制。


推荐阅读