-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcloudbuild.yaml
82 lines (76 loc) · 2.13 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
steps:
# Build the image
- name: 'gcr.io/cloud-builders/docker'
args:
[
'build',
'--build-arg',
'PYTHON_VERSION=3.10.11',
'-t',
'asia-southeast2-docker.pkg.dev/$PROJECT_ID/singa-backend/singa-predict-api:latest',
'.',
]
env:
- DOCKER_BUILDKIT=1
# Push the image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args:
[
'push',
'asia-southeast2-docker.pkg.dev/$PROJECT_ID/singa-backend/singa-predict-api:latest',
]
# Deploy the new image
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args: [
'run',
'deploy',
'singa-predict-api',
'--image',
'asia-southeast2-docker.pkg.dev/$PROJECT_ID/singa-backend/singa-predict-api:latest',
'--region',
'asia-southeast2',
'--min-instances',
$_MIN_INSTANCES,
'--memory',
$_MEMORY,
'--platform',
'managed',
'--allow-unauthenticated',
'--port',
$_CUSTOM_PORT,
'--ingress',
'internal',
'--vpc-connector',
$_VPC_CONNECTOR,
'--vpc-egress',
'private-ranges-only',
'--service-account',
$SERVICE_ACCOUNT_EMAIL,
# Set required env
'--set-env-vars',
'HOST=${_HOST}',
'--set-env-vars',
'MODEL_PATH=models/${_MODEL_NAME}',
# Set the env secrets
'--set-secrets',
'GCLOUD_STORAGE_BUCKET=bucket-name:latest',
]
# Configure build log
logsBucket: gs://$_LOGBUCKET_NAME
serviceAccount: 'projects/$PROJECT_ID/serviceAccounts/$_SERVICE_ACCOUNT'
# Substitution Value
substitutions:
_HOST: '0.0.0.0'
_CUSTOM_PORT: '4000'
_MIN_INSTANCES: '1'
_MEMORY: 4Gi
_MODEL_NAME: your-model-name
_SERVICE_ACCOUNT: your-sa-for-build
_LOGBUCKET_NAME: your-log-bucket-name
_VPC_CONNECTOR: your-vpc-connector
options:
logging: GCS_ONLY
dynamicSubstitutions: true
images:
- 'asia-southeast2-docker.pkg.dev/$PROJECT_ID/singa-backend/singa-predict-api:latest'