Google 云功能:缺少 main.py
Google Cloud Functions: missing main.py
尝试使用命令将 Python 项目部署到 Google 云函数时
gcloud functions deploy my_function --entry-point reply --runtime python38 --trigger-http --allow-unauthenticated
我明白了
Deploying function (may take a while - up to 2 minutes)...⠛
For Cloud Build Stackdriver Logs, visit:
https://[...]
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build
failed: missing main.py and GOOGLE_FUNCTION_SOURCE not specified.
Either create the function in main.py or specify
GOOGLE_FUNCTION_SOURCE to point to the file that contains the
function; Error ID: 5c04ec9c
但我的文件夹中确实有一个 main.py
文件。
我检查了平台,文件main.py
没有被上传,而文件夹中的文件被上传了。
解决方案是从 .gcloudignore
:
中省略这一行
#!include:.gitignore
我不太明白为什么。
我的.gitignore
是:
.*
*.json
.gcloudignore
的内容对我很有帮助。我从其他一些已经有这个自动生成文件的项目中复制了它。
文件名:.gcloudignore
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
node_modules
尝试使用命令将 Python 项目部署到 Google 云函数时
gcloud functions deploy my_function --entry-point reply --runtime python38 --trigger-http --allow-unauthenticated
我明白了
Deploying function (may take a while - up to 2 minutes)...⠛
For Cloud Build Stackdriver Logs, visit: https://[...] Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function; Error ID: 5c04ec9c
但我的文件夹中确实有一个 main.py
文件。
我检查了平台,文件main.py
没有被上传,而文件夹中的文件被上传了。
解决方案是从 .gcloudignore
:
#!include:.gitignore
我不太明白为什么。
我的.gitignore
是:
.*
*.json
.gcloudignore
的内容对我很有帮助。我从其他一些已经有这个自动生成文件的项目中复制了它。
文件名:.gcloudignore
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore
node_modules