如何在git上构造多个功能以在Google Cloud Functions上自动部署?
问题描述:
我开始使用Google Cloud Functions,并且已经看到可以从bitbucket进行自动部署的选项.我有多个功能要部署,每个功能应该有一个存储库,还是可以有一个存储库,但可以按目录或其他方式划分?
I'm start using the Google Cloud Functions and I've see that has an option to make an automated deploy from the bitbucket. I have multiple functions to deploy, should I have one repo per functions or can I have one repo but divided by directories or something else?
这就是我在说的: 从源代码管理进行部署
谢谢.
答
您可以在一个存储库中具有多个功能.常见的结构如下:
You can have multiple functions in a single repo. A common structure would be as follows:
.
├── common
│ ├── module1.py
│ └── module2.py
├── main.py
└── requirements.txt
main.py
包含两个功能:
from common import module1, module2
def cloudfunction1(request):
...
def cloudfunction2(request):
...
然后直接按名称部署这些功能:
And you deploy those functions either directly by name:
$ gcloud beta functions deploy cloudfunction1 --runtime python37 --trigger-http --source https://source.developers.google.com/...
$ gcloud beta functions deploy cloudfunction2 --runtime python37 --trigger-http --source https://source.developers.google.com/...
或按入口点:
$ gcloud beta functions deploy foo --runtime python37 --entry-point cloudfunction1 --trigger-http --source https://source.developers.google.com/...
$ gcloud beta functions deploy bar --runtime python37 --entry-point cloudfunction2 --trigger-http --source https://source.developers.google.com/...