-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
105 lines (95 loc) · 3.36 KB
/
cloudbuild.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
substitutions:
_RUNTIME: nodejs18
_SERVICE_NAME: member
_REGION: us-central1
_SUMMARIZE_ENTRY_POINT: summarize
_SUMMARIZE_TOPIC: summarize_chat
_INIT_CHAT_ENTRY_POINT: initChat
_INIT_CHAT_TOPIC: init_chat
options:
automapSubstitutions: true
substitutionOption: 'ALLOW_LOOSE'
steps:
# Build Cloud Run service
- name: 'gcr.io/cloud-builders/docker'
id: 'build-docker'
args: ['build', '-t', 'gcr.io/${PROJECT_ID}/${_SERVICE_NAME}:latest', '.']
# Push Cloud Run service
- name: 'gcr.io/cloud-builders/docker'
id: 'push-docker'
args: ['push', 'gcr.io/${PROJECT_ID}/${_SERVICE_NAME}:latest']
waitFor: ['build-docker']
# Deploy to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:latest'
id: 'deploy-cloud-run'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud run deploy ${_SERVICE_NAME}-app \
--image=gcr.io/${PROJECT_ID}/${_SERVICE_NAME}:latest \
--region=${_REGION} \
--platform=managed \
--memory=2Gi \
--cpu=2 \
--timeout=10m \
--project=${PROJECT_ID} \
--set-env-vars="\
ENV=${_ENV},\
MESSAGE_CRYPTO_KEY=${_MESSAGE_CRYPTO_KEY},\
OPENAI_API_KEY=${_OPENAI_API_KEY},\
SMTP_EMAIL=${_SMTP_EMAIL},\
SMTP_HOST=${_SMTP_HOST},\
SMTP_PASSWORD=${_SMTP_PASSWORD}, \
DATABASE_ID=${_DATABASE_ID}" \
--allow-unauthenticated
waitFor: ['push-docker']
# Install dependencies for Cloud Function
- name: 'gcr.io/cloud-builders/npm'
id: 'npm-install'
args: ['install']
# Build for Cloud Function
- name: 'gcr.io/cloud-builders/npm'
id: 'npm-build'
args: ['run', 'build']
waitFor: ['npm-install']
# Deploy Cloud Function
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:latest'
id: 'deploy-summarize-cloud-function'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud functions deploy ${_SUMMARIZE_ENTRY_POINT}-api \
--gen2 \
--runtime=${_RUNTIME} \
--trigger-topic ${_SUMMARIZE_TOPIC} \
--allow-unauthenticated \
--timeout=8m \
--region=${_REGION} \
--project=${PROJECT_ID} \
--entry-point=${_SUMMARIZE_ENTRY_POINT} \
--set-env-vars="ENV=${_ENV},MESSAGE_CRYPTO_KEY=${_MESSAGE_CRYPTO_KEY},OPENAI_API_KEY=${_OPENAI_API_KEY},SMTP_EMAIL=${_SMTP_EMAIL},SMTP_HOST=${_SMTP_HOST},SMTP_PASSWORD=${_SMTP_PASSWORD},DATABASE_ID=${_DATABASE_ID}" \
--memory=1Gb
waitFor: ['npm-build']
# Deploy INIT Cloud Function
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:latest'
id: 'deploy-init-chat-cloud-function'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud functions deploy ${_INIT_CHAT_ENTRY_POINT}-api \
--gen2 \
--runtime=${_RUNTIME} \
--trigger-topic ${_INIT_CHAT_TOPIC} \
--allow-unauthenticated \
--timeout=8m \
--region=${_REGION} \
--project=${PROJECT_ID} \
--entry-point=${_INIT_CHAT_ENTRY_POINT} \
--set-env-vars="ENV=${_ENV},MESSAGE_CRYPTO_KEY=${_MESSAGE_CRYPTO_KEY},OPENAI_API_KEY=${_OPENAI_API_KEY},SMTP_EMAIL=${_SMTP_EMAIL},SMTP_HOST=${_SMTP_HOST},SMTP_PASSWORD=${_SMTP_PASSWORD},DATABASE_ID=${_DATABASE_ID}" \
--memory=1Gb
waitFor: ['npm-build']
images:
- 'gcr.io/${PROJECT_ID}/${_SERVICE_NAME}:latest'