-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
57 lines (53 loc) · 1.64 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
steps:
# Install Node.js dependencies
- id: npm-install
name: node:16
entrypoint: npm
args: ["install", "--frozen-lockfile"]
waitFor: ["-"]
- id: migrate
name: "gcr.io/cloud-builders/npm"
env:
- NODE_ENV=$_NODE_ENV
entrypoint: sh
args:
- "-c"
- |
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy
./cloud_sql_proxy -instances=$_INSTANCE & sleep 3
export DATABASE_URL=mysql://$$_DB_USER:[email protected]:3306/$$_DB_NAME
npx prisma migrate deploy
secretEnv: ["_DB_USER", "_DB_PASS", "_DB_NAME"]
timeout: "1300s"
waitFor: ["npm-install"]
- id: build
name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA", "."]
- id: push
name: "gcr.io/cloud-builders/docker"
args: ["push", "gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA"]
- id: deploy
name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: gcloud
args:
[
"run",
"deploy",
"$_SERVICE_NAME",
"--image",
"gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA",
"--region",
"$_DEPLOY_REGION",
]
images: ["gcr.io/$PROJECT_ID/$_SERVICE_NAME:$COMMIT_SHA"]
options:
substitutionOption: ALLOW_LOOSE
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/DB_NAME/versions/latest
env: "_DB_NAME"
- versionName: projects/$PROJECT_ID/secrets/DB_PASS/versions/latest
env: "_DB_PASS"
- versionName: projects/$PROJECT_ID/secrets/DB_USER/versions/latest
env: "_DB_USER"