首页 > 解决方案 > Google Cloud Build 找不到 Python venv... 对于 Java Spring Boot 项目

问题描述

我现在有一个部署到 Heroku 的常用 Java 11 Spring Boot 应用程序。

我可以通过本地调用手动将应用程序部署到 AppEnginegcloud app deploy

但是,为了让 Google Cloud Build 自动构建和部署应用程序,我苦苦挣扎了大约 2 个小时。它崩溃无法找到python,但我完全不知道为什么它仍然试图寻找python。

这是cloubuild.yaml

  - name: maven:3.6.3-adoptopenjdk-11
    entrypoint: mvn
    args: ['--version']

  - name: maven:3.6.3-adoptopenjdk-11
    entrypoint: mvn
    args: ['package']

  - name: 'gcr.io/cloud-builders/gcloud'
    args: ['app', 'deploy', 'app.yaml']

这是同一根文件夹中的应用 yaml:

runtime: java11
env: standard
instance_class: F2
automatic_scaling:
  max_instances: 1

这是输出的错误部分:

Step #2: descriptor:      [/workspace/app.yaml]
Step #2: source:          [/workspace]
Step #2: target project:  [atomic-parity-282520]
Step #2: target service:  [default]
Step #2: target version:  [20200711t113051]
Step #2: target url:      [https://atomic-parity-282520.ew.r.appspot.com]
Step #2: 
Step #2: 
Step #2: Do you want to continue (Y/n)?  
Step #2: Beginning deployment of service [default]...
Step #2: Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
Step #2: ERROR: gcloud crashed (OSError): [Errno 2] No such file or directory: '/workspace/venv/bin/python3'
Step #2: 
Step #2: If you would like to report this issue, please run the following command:
Step #2:   gcloud feedback
Step #2: 
Step #2: To check gcloud for common problems, please run the following command:
Step #2:   gcloud info --run-diagnostics
Finished Step #2
ERROR
ERROR: build step 2 "gcr.io/cloud-builders/gcloud" failed: step exited with non-zero status: 1

标签: javapythongoogle-cloud-platformgcloudgoogle-cloud-build

解决方案


似乎前段时间我们添加了一些用于数据库迁移的 python 脚本。除了脚本之外,venv还创建了一个文件夹。

看起来 AppEngine 触发它作为该项目基于 Python 的线索,即使您设置了特定app.yaml的使用 Java 的指示。

删除venv文件夹解决了这个问题。


推荐阅读