-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcloudbuild.yaml
130 lines (124 loc) · 3.93 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
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
steps:
# Build the image
- name: 'gcr.io/cloud-builders/docker'
args:
[
'build',
'--build-arg',
'NODE_VERSION=20.12.0',
'-t',
'asia-southeast2-docker.pkg.dev/$PROJECT_ID/singa-backend/singa-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-api:latest']
# Deploy the new image
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args: [
'run',
'deploy',
'singa-api',
'--image',
'asia-southeast2-docker.pkg.dev/$PROJECT_ID/singa-backend/singa-api:latest',
'--region',
'asia-southeast2',
'--min-instances',
$_MIN_INSTANCES,
'--platform',
'managed',
'--allow-unauthenticated',
'--port',
$_CUSTOM_PORT,
'--vpc-connector',
$_VPC_CONNECTOR,
'--vpc-egress',
'all-traffic',
'--service-account',
$SERVICE_ACCOUNT_EMAIL,
# Set required env
'--set-env-vars',
'TZ=UTC',
'--set-env-vars',
'HOST=${_HOST}',
'--set-env-vars',
'LOG_LEVEL=info',
'--set-env-vars',
'NODE_ENV=production',
'--set-env-vars',
'ADMINS=1',
'--set-env-vars',
'LIMITER_STORE=database',
'--set-env-vars',
'DRIVE_ROOT=${_DRIVE_ROOT}',
'--set-env-vars',
'DRIVE_NAME=${_DRIVE_NAME}',
'--set-env-vars',
'APP_URL=http://${_HOST}:${_CUSTOM_PORT}',
'--set-env-vars',
'STATIC_STORAGE_PATH=static-translation',
'--set-env-vars',
'CONVERSATION_STORAGE_PATH=conversation-translation',
'--set-env-vars',
'STATIC_QUOTA=10485760', # in bytes (10MB)
'--set-env-vars',
'GUEST_QUOTA=104857600', # in bytes (100MB)
'--set-env-vars',
'USER_QUOTA=1073741824', # in bytes (1024MB/1GB)
'--set-env-vars',
'DB_PORT=5432',
'--set-env-vars',
'QUEUE_REDIS_PORT=6379',
'--set-env-vars',
'GOOGLE_CLOUD_STORAGE_STORAGE_PATH=${_DRIVE_NAME}',
# Set the env secrets
'--set-secrets',
'ADMIN_PASSWORD=admin-password:latest',
'--set-secrets',
'APP_KEY=app-key:latest',
'--set-secrets',
'DB_HOST=postgresql-db-host:latest',
'--set-secrets',
'DB_USER=postgresql-db-user:latest',
'--set-secrets',
'DB_PASSWORD=postgresql-db-password:latest',
'--set-secrets',
'DB_DATABASE=postgresql-db-database:latest',
'--set-secrets',
'QUEUE_REDIS_HOST=redis-host:latest',
'--set-secrets',
'GITHUB_CLIENT_ID=github-client-id:latest',
'--set-secrets',
'GITHUB_CLIENT_SECRET=github-client-secret:latest',
'--set-secrets',
'GOOGLE_CLIENT_ID=google-client-id:latest',
'--set-secrets',
'GOOGLE_CLIENT_SECRET=google-client-secret:latest',
'--set-secrets',
'GITHUB_CLIENT_CALLBACK_URL=github-client-callback-url:latest',
'--set-secrets',
'GOOGLE_CLIENT_CALLBACK_URL=google-client-callback-url:latest',
'--set-secrets',
'GOOGLE_CLOUD_STORAGE_BUCKET_NAME=bucket-name:latest',
'--set-secrets',
'PREDICT_API_HOST=predict-api-host: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: '3333'
_MIN_INSTANCES: '1'
_DRIVE_ROOT: ./uploads
_DRIVE_NAME: uploads
_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-api:latest'