-
Notifications
You must be signed in to change notification settings - Fork 186
/
cloudbuild-main.yaml
138 lines (130 loc) · 4.37 KB
/
cloudbuild-main.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
131
132
133
134
135
136
137
138
# lit.dev Cloud Build config for main branch auto deployment.
#
# https://cloud.google.com/cloud-build/docs/build-config
steps:
# Build Docker image.
#
# https://docs.docker.com/engine/reference/commandline/build/
# https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/docker
# https://cloud.google.com/build/docs/kaniko-cache
- id: build
name: gcr.io/kaniko-project/executor:latest
args:
- --dockerfile=./Dockerfile
- --destination=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA
- --cache=true
- --cache-ttl=168h # 1 week
- --build-arg=LITDEV_ENV=prod
- --build-arg=SHORT_SHA=$SHORT_SHA
# Create a new Cloud Run revision for the main site.
#
# https://cloud.google.com/sdk/gcloud/reference/beta/run/deploy
# https://github.com/GoogleCloudPlatform/cloud-sdk-docker
- id: deploy-main
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
args:
- beta
- run
- deploy
- lit-dev # Service name
- '--region=$_DEPLOY_REGION'
- '--platform=managed'
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA'
- '--quiet'
- '--no-traffic'
# If this tag format changes, also update route-traffic- steps below and
# the cleanup script in packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
- '--tag=main-$SHORT_SHA'
# IMPORTANT: If you change --memory, be sure to also change
# --max-old-space-size in ./Dockerfile, and this same flag in
# ./cloudbuild-pr.yaml
- '--memory=1Gi'
- '--cpu=1'
- '--concurrency=200'
- '--min-instances=1'
- '--max-instances=1000'
- '--set-secrets=GITHUB_CLIENT_SECRET=lit-dev-playground-github-oauth-client-secret-prod:1'
# Serve the main site
- '--update-env-vars=LITDEV_ENV=prod,MODE=main'
# Create a new Cloud Run revision for the Playground sandbox.
#
# https://cloud.google.com/sdk/gcloud/reference/beta/run/deploy
# https://github.com/GoogleCloudPlatform/cloud-sdk-docker
- id: deploy-playground
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
waitFor:
# Don't wait for main site deploy
- build
args:
- beta
- run
- deploy
- lit-dev-playground # Service name
- '--region=$_DEPLOY_REGION'
- '--platform=managed'
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/lit-dev:$COMMIT_SHA'
- '--quiet'
- '--no-traffic'
# If this tag format changes, also update route-traffic- steps below and
# the cleanup script in packages/lit-dev-cloudbuild-cleanup/src/cleanup.ts
- '--tag=main-$SHORT_SHA'
# IMPORTANT: If you change --memory, be sure to also change
# --max-old-space-size in ./Dockerfile, and this same flag in
# ./cloudbuild-pr.yaml
- '--memory=1Gi'
- '--cpu=1'
- '--concurrency=200'
- '--min-instances=1'
- '--max-instances=1000'
# Serve the playground files
- '--update-env-vars=LITDEV_ENV=prod,MODE=playground'
# Route traffic to new revision for the playground.
#
# https://cloud.google.com/sdk/gcloud/reference/beta/run/services
# https://github.com/GoogleCloudPlatform/cloud-sdk-docker
- id: route-traffic-main
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
waitFor:
# Route traffic simultaneously once both deploys are done
- deploy-main
- deploy-playground
args:
- beta
- run
- services
- update-traffic
- lit-dev # Service name
- '--region=$_DEPLOY_REGION'
- '--platform=managed'
- '--quiet'
- '--to-tags=main-$SHORT_SHA=100'
# Route traffic to new revision for the main site.
#
# https://cloud.google.com/sdk/gcloud/reference/beta/run/services
# https://github.com/GoogleCloudPlatform/cloud-sdk-docker
- id: route-traffic-playground
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
waitFor:
# Route traffic simultaneously once both deploys are done
- deploy-main
- deploy-playground
args:
- beta
- run
- services
- update-traffic
- lit-dev-playground # Service name
- '--region=$_DEPLOY_REGION'
- '--platform=managed'
- '--quiet'
- '--to-tags=main-$SHORT_SHA=100'
tags:
- lit-dev
- cloudbuild-main
options:
machineType: 'N1_HIGHCPU_8'
timeout: 45m