-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
218 lines (204 loc) · 7.93 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
218 lines (204 loc) · 7.93 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
substitutions:
_DEPLOY_TARGET: none
_REGION: us-central1
_ARTIFACT_REGISTRY_REPO: resonancelab
_WEB_IMAGE: resonancelab-web
_API_IMAGE: resonancelab-api
_WEB_SERVICE: resonancelab-web
_API_SERVICE: resonancelab-api
_RUN_SERVICE_ACCOUNT: resonancelab-run
_WEB_MEMORY: 512Mi
_WEB_CPU: "1"
_WEB_CONCURRENCY: "80"
_WEB_MIN_INSTANCES: "0"
_WEB_MAX_INSTANCES: "3"
_WEB_TIMEOUT: 30s
_API_MEMORY: 1Gi
_API_CPU: "1"
_API_CONCURRENCY: "2"
_API_MIN_INSTANCES: "0"
_API_MAX_INSTANCES: "3"
_API_TIMEOUT: 45s
_API_MAX_UPLOAD_BYTES: "8388608"
_API_MAX_RECORDING_SECONDS: "8.0"
_EXTRA_CORS_ORIGINS: none
_LLM_ENABLED: "false"
_LLM_PROVIDER: vertex_gemini
_LLM_MODEL: gemini-3.1-pro-preview
_LLM_LOCATION: global
_LLM_THINKING_LEVEL: HIGH
_LLM_MAX_OUTPUT_TOKENS: "8192"
_GOOGLE_GENAI_USE_ENTERPRISE: "true"
options:
logging: CLOUD_LOGGING_ONLY
steps:
- id: project-hygiene-and-api-tests
name: python:3.13-slim@sha256:c33f0bc4364a6881bed1ec0cc2665e6c53c87a43e774aaeab88e6f17af105e4f
entrypoint: bash
args:
- -c
- |
python -m pip install -r requirements-dev.txt
python scripts/check_supply_chain.py
python scripts/check_project_docs.py --all
python -m compileall packages services/api scripts
python -m ruff check .
python -m pytest
- id: web-check-and-build
name: node:22-slim@sha256:d9f850096136edbc402debdd8729579a288aac64574ada0ff4db26b6ae58b0b2
entrypoint: bash
args:
- -c
- |
npm ci
npm --workspace @resonancelab/web run check
npm --workspace @resonancelab/web run test
npm --workspace @resonancelab/web run build
- id: build-api-image
name: gcr.io/cloud-builders/docker@sha256:d7e6d16d720cb25ac16d3bd49f213d8ae4b3b0e45797b89e10eaee07ef7877a5
args:
- build
- -f
- services/api/Dockerfile
- -t
- ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_ARTIFACT_REGISTRY_REPO}/${_API_IMAGE}:$BUILD_ID
- .
- id: build-web-image
name: gcr.io/cloud-builders/docker@sha256:d7e6d16d720cb25ac16d3bd49f213d8ae4b3b0e45797b89e10eaee07ef7877a5
args:
- build
- -f
- apps/web/Dockerfile
- -t
- ${_REGION}-docker.pkg.dev/$PROJECT_ID/${_ARTIFACT_REGISTRY_REPO}/${_WEB_IMAGE}:$BUILD_ID
- .
- id: push-api-image
name: gcr.io/cloud-builders/docker@sha256:d7e6d16d720cb25ac16d3bd49f213d8ae4b3b0e45797b89e10eaee07ef7877a5
entrypoint: bash
args:
- -c
- |
case "${_DEPLOY_TARGET}" in
cloud-run) ;;
*)
echo "Skipping API image push because _DEPLOY_TARGET=${_DEPLOY_TARGET}."
exit 0
;;
esac
docker push "${_REGION}-docker.pkg.dev/$PROJECT_ID/${_ARTIFACT_REGISTRY_REPO}/${_API_IMAGE}:$BUILD_ID"
- id: push-web-image
name: gcr.io/cloud-builders/docker@sha256:d7e6d16d720cb25ac16d3bd49f213d8ae4b3b0e45797b89e10eaee07ef7877a5
entrypoint: bash
args:
- -c
- |
case "${_DEPLOY_TARGET}" in
cloud-run) ;;
*)
echo "Skipping web image push because _DEPLOY_TARGET=${_DEPLOY_TARGET}."
exit 0
;;
esac
docker push "${_REGION}-docker.pkg.dev/$PROJECT_ID/${_ARTIFACT_REGISTRY_REPO}/${_WEB_IMAGE}:$BUILD_ID"
- id: deploy-api
name: gcr.io/google.com/cloudsdktool/cloud-sdk@sha256:02ba53c5a1920500dfb193777595f019be4d81802207e99fd97504cb4fadb873
entrypoint: bash
args:
- -c
- |
if [ "${_DEPLOY_TARGET}" != "cloud-run" ]; then
echo "Skipping API deploy because _DEPLOY_TARGET=${_DEPLOY_TARGET}."
exit 0
fi
case "${_LLM_ENABLED}" in
true|false) ;;
*)
echo "_LLM_ENABLED must be true or false."
exit 1
;;
esac
if [ "${_LLM_PROVIDER}" != "vertex_gemini" ]; then
echo "_LLM_PROVIDER must be vertex_gemini."
exit 1
fi
case "${_LLM_THINKING_LEVEL}" in
LOW|MEDIUM|HIGH|MINIMAL) ;;
*)
echo "_LLM_THINKING_LEVEL must be LOW, MEDIUM, HIGH, or MINIMAL."
exit 1
;;
esac
case "${_LLM_MAX_OUTPUT_TOKENS}" in
''|*[!0-9]*)
echo "_LLM_MAX_OUTPUT_TOKENS must be a positive integer."
exit 1
;;
esac
if [ "${_LLM_MAX_OUTPUT_TOKENS}" -lt 1 ]; then
echo "_LLM_MAX_OUTPUT_TOKENS must be a positive integer."
exit 1
fi
LLM_ENV="|RESONANCELAB_LLM_ENABLED=${_LLM_ENABLED}|RESONANCELAB_LLM_PROVIDER=${_LLM_PROVIDER}|RESONANCELAB_LLM_PROJECT_ID=$PROJECT_ID|RESONANCELAB_LLM_LOCATION=${_LLM_LOCATION}|RESONANCELAB_LLM_MODEL=${_LLM_MODEL}|RESONANCELAB_LLM_THINKING_LEVEL=${_LLM_THINKING_LEVEL}|RESONANCELAB_LLM_MAX_OUTPUT_TOKENS=${_LLM_MAX_OUTPUT_TOKENS}|GOOGLE_CLOUD_PROJECT=$PROJECT_ID|GOOGLE_CLOUD_LOCATION=${_LLM_LOCATION}|GOOGLE_GENAI_USE_ENTERPRISE=${_GOOGLE_GENAI_USE_ENTERPRISE}"
gcloud run deploy "${_API_SERVICE}" \
--image "${_REGION}-docker.pkg.dev/$PROJECT_ID/${_ARTIFACT_REGISTRY_REPO}/${_API_IMAGE}:$BUILD_ID" \
--region "${_REGION}" \
--platform managed \
--execution-environment=gen2 \
--cpu-boost \
--allow-unauthenticated \
--service-account "${_RUN_SERVICE_ACCOUNT}@$PROJECT_ID.iam.gserviceaccount.com" \
--memory "${_API_MEMORY}" \
--cpu "${_API_CPU}" \
--concurrency "${_API_CONCURRENCY}" \
--min-instances "${_API_MIN_INSTANCES}" \
--max-instances "${_API_MAX_INSTANCES}" \
--timeout "${_API_TIMEOUT}" \
--set-env-vars "^|^RESONANCELAB_ENV=cloud|RESONANCELAB_MAX_UPLOAD_BYTES=${_API_MAX_UPLOAD_BYTES}|RESONANCELAB_MAX_RECORDING_SECONDS=${_API_MAX_RECORDING_SECONDS}$${LLM_ENV}"
- id: deploy-web
name: gcr.io/google.com/cloudsdktool/cloud-sdk@sha256:02ba53c5a1920500dfb193777595f019be4d81802207e99fd97504cb4fadb873
entrypoint: bash
args:
- -c
- |
if [ "${_DEPLOY_TARGET}" != "cloud-run" ]; then
echo "Skipping web deploy because _DEPLOY_TARGET=${_DEPLOY_TARGET}."
exit 0
fi
API_URL="https://${_API_SERVICE}-$PROJECT_NUMBER.${_REGION}.run.app"
gcloud run deploy "${_WEB_SERVICE}" \
--image "${_REGION}-docker.pkg.dev/$PROJECT_ID/${_ARTIFACT_REGISTRY_REPO}/${_WEB_IMAGE}:$BUILD_ID" \
--region "${_REGION}" \
--platform managed \
--execution-environment=gen2 \
--cpu-boost \
--allow-unauthenticated \
--service-account "${_RUN_SERVICE_ACCOUNT}@$PROJECT_ID.iam.gserviceaccount.com" \
--memory "${_WEB_MEMORY}" \
--cpu "${_WEB_CPU}" \
--concurrency "${_WEB_CONCURRENCY}" \
--min-instances "${_WEB_MIN_INSTANCES}" \
--max-instances "${_WEB_MAX_INSTANCES}" \
--timeout "${_WEB_TIMEOUT}" \
--set-env-vars "PUBLIC_API_URL=$${API_URL},RESONANCELAB_ENV=cloud"
- id: update-api-cors
name: gcr.io/google.com/cloudsdktool/cloud-sdk@sha256:02ba53c5a1920500dfb193777595f019be4d81802207e99fd97504cb4fadb873
entrypoint: bash
args:
- -c
- |
if [ "${_DEPLOY_TARGET}" != "cloud-run" ]; then
echo "Skipping API CORS update because _DEPLOY_TARGET=${_DEPLOY_TARGET}."
exit 0
fi
WEB_URL="$$(gcloud run services describe "${_WEB_SERVICE}" --region "${_REGION}" --format='value(status.url)')"
WEB_CANONICAL_URL="https://${_WEB_SERVICE}-$PROJECT_NUMBER.${_REGION}.run.app"
CORS_ORIGINS="$${WEB_URL}"
if [ "$${WEB_CANONICAL_URL}" != "$${WEB_URL}" ]; then
CORS_ORIGINS="$${CORS_ORIGINS},$${WEB_CANONICAL_URL}"
fi
if [ "${_EXTRA_CORS_ORIGINS}" != "none" ]; then
CORS_ORIGINS="$${CORS_ORIGINS},${_EXTRA_CORS_ORIGINS}"
fi
gcloud run services update "${_API_SERVICE}" \
--region "${_REGION}" \
--update-env-vars "^|^RESONANCELAB_CORS_ORIGINS=$${CORS_ORIGINS}"