0
votes

When trying to deploy a Python project to Google Cloud functions using the command

gcloud functions deploy my_function --entry-point reply --runtime python38 --trigger-http --allow-unauthenticated

I get

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

But I do have a main.py file in the folder.

I checked the platform and the file main.py is not being uploaded, while the files inside folders are.

2

2 Answers

1
votes

The solution was to omit this line from .gcloudignore:

#!include:.gitignore

I don't really understand why.

My .gitignore is:

.*
*.json
0
votes

The content of .gcloudignore which worked for me like a charm. I copied it from some other project which already had this autogenerated file.

FileName: .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