-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathdeploy-main.yaml
124 lines (115 loc) · 3.24 KB
/
deploy-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
# Cloud Build config for main branch auto deployment of webcomponents.org.
timeout: 10m
options:
# https://cloud.google.com/build/docs/api/reference/rest/v1/projects.builds#machinetype
machineType: N1_HIGHCPU_8
dynamic_substitutions: true
substitutions:
_REGION: us-central1
_TAG: main-${SHORT_SHA}
_IMAGE_URL_CATALOG: us.gcr.io/${PROJECT_ID}/main/catalog:${SHORT_SHA}
_IMAGE_URL_SITE: us.gcr.io/${PROJECT_ID}/main/site:${SHORT_SHA}
_IMAGE_CACHE_TTL: 168h # 1 week
_CATALOG_SERVER_AUTH_ID: https://catalog-24wnpwhcla-uc.a.run.app
_CATALOG_GRAPHQL_URL: https://new-catalog.webcomponents.org/graphql
steps:
# Build catalog Docker image.
- id: build-catalog
waitFor: ['-'] # Start immediately
name: gcr.io/kaniko-project/executor:latest
args:
- --dockerfile=./docker/catalog/Dockerfile
- --destination=${_IMAGE_URL_CATALOG}
- --cache=true
- --cache-ttl=${_IMAGE_CACHE_TTL}
# Build site Docker image.
- id: build-site
waitFor: ['-'] # Start immediately
name: gcr.io/kaniko-project/executor:latest
args:
- --dockerfile=./docker/site/Dockerfile
- --destination=${_IMAGE_URL_SITE}
- --cache=true
- --cache-ttl=${_IMAGE_CACHE_TTL}
# Create catalog Cloud Run revision.
- id: deploy-catalog
waitFor:
- build-catalog
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
args:
- beta
- run
- deploy
- catalog
- --region=${_REGION}
- --platform=managed
- --image=${_IMAGE_URL_CATALOG}
- --quiet
- --no-traffic
- --tag=${_TAG}
- --memory=1Gi
- --cpu=1
- --concurrency=200
- --min-instances=1
- --max-instances=4
- --update-env-vars=GCP_PROJECT_ID=${PROJECT_ID}
# Create site Cloud Run revision.
- id: deploy-site
waitFor:
- build-site
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
args:
- beta
- run
- deploy
- site
- --region=${_REGION}
- --platform=managed
- --image=${_IMAGE_URL_SITE}
- --quiet
- --no-traffic
- --tag=${_TAG}
- --memory=1Gi
- --cpu=1
- --concurrency=200
- --min-instances=1
- --max-instances=4
- --update-env-vars=CATALOG_GRAPHQL_URL=${_CATALOG_GRAPHQL_URL},CATALOG_SERVER_AUTH_ID=${_CATALOG_SERVER_AUTH_ID}
# Route traffic to new catalog revision.
- id: route-catalog
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
waitFor:
# Wait for both deploys so that both revisions go live at similar times
- deploy-catalog
- deploy-site
args:
- beta
- run
- services
- update-traffic
- catalog
- --region=${_REGION}
- --platform=managed
- --quiet
- --to-tags=${_TAG}=100
# Route traffic to new site revision.
- id: route-site
name: gcr.io/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
waitFor:
# Wait for both deploys so that both revisions go live at similar times
- deploy-catalog
- deploy-site
args:
- beta
- run
- services
- update-traffic
- site
- --region=${_REGION}
- --platform=managed
- --quiet
- --to-tags=${_TAG}=100