You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CloudDeploy流水线触发报错:Python入口点未识别(已配置Procfile)

问题描述

用Cloud Build + Cloud Deploy自动化GKE部署时,触发流水线后报以下错误:

Failed to run /bin/build: for Python, an entrypoint must be manually set, either with "GOOGLE_ENTRYPOINT" env var or by creating a "Procfile" file"

已在代码根目录(与cloudbuild.yaml、clouddeploy.yaml同目录)创建Procfile,内容为:

web: gunicorn --bind :8080 main:app

相关配置文件如下:

cloudbuild.yaml

steps:
- name: 'gcr.io/k8s-skaffold/pack'
  entrypoint: 'pack'
  args: ['build', '--builder=gcr.io/buildpacks/builder', '--publish', 'us-east1-docker.pkg.dev/fakeproject/my-docker-repo/app3:$SHORT_SHA']
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  entrypoint: 'bash'
  args:
  - '-c'
  - > 
    gcloud deploy releases create release-$BUILD_ID
    --delivery-pipeline=app3
    --region=us-east1
    --source=./
    --images=app3=us-east1-docker.pkg.dev/fakeproject/my-docker-repo/app3:$SHORT_SHA
options:
  logging: CLOUD_LOGGING_ONLY

clouddeploy.yaml

---
apiVersion: deploy.cloud.google.com/v1beta1
kind: DeliveryPipeline
metadata:
  name: app3
description: App3 Deployment Pipeline 
serialPipeline:
  stages:
  - targetId: demo-gke
---
apiVersion: deploy.cloud.google.com/v1beta1
kind: Target
metadata:
  name: demo-gke
description: Demo Environment
gke:
  cluster: projects/fakeproject/locations/us-east1/clusters/demo-gke
executionConfigs:
- usages:
  - DEPLOY
  workerPool: "projects/fakeproject/locations/us-east1/workerPools/cloud-build-pool"
- usages:
  - RENDER
  - VERIFY

main.py

from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
    return "Hello from app3"
# run the app.
if __name__ == "__main__":
    app.run()

requirements.txt和skaffold.yaml与参考教程完全一致。

解决方案
  • 严格校验Procfile的命名与位置:必须用大写P开头的Procfile(不能是小写procfile或其他变体),且必须放在Cloud Build构建使用的源代码根目录下。Google Cloud Buildpacks对文件名大小写敏感,命名错误会直接忽略该文件。
  • 直接在pack命令中强制指定入口点:如果Procfile仍未被识别,无需纠结,直接修改cloudbuild.yaml的第一个步骤,通过环境变量硬设入口点:
    steps:
    - name: 'gcr.io/k8s-skaffold/pack'
      entrypoint: 'pack'
      args: [
        'build', 
        '--builder=gcr.io/buildpacks/builder', 
        '--publish', 'us-east1-docker.pkg.dev/fakeproject/my-docker-repo/app3:$SHORT_SHA',
        '--env', 'GOOGLE_ENTRYPOINT="gunicorn --bind :8080 main:app"'
      ]
    
  • 检查Cloud Build的源代码上下文:确认触发器配置的代码分支中确实包含Procfile,且未被.gitignore或构建排除规则过滤,避免拉取错误分支或遗漏文件。
  • 排查skaffold.yaml的覆盖配置:如果skaffold.yaml中定义了command或args字段,会直接覆盖Buildpacks设置的入口点。要么删除这些配置,要么修改为与Procfile一致的指令。
  • 确认requirements.txt包含gunicorn依赖:确保requirements.txt中添加了gunicorn,避免后续容器启动时因依赖缺失报错。

内容的提问来源于stack exchange,提问作者Gary Turner

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 04:55:28