-
Notifications
You must be signed in to change notification settings - Fork 17
/
cloudbuild.yaml
55 lines (51 loc) · 2.14 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
# Cloud Build builders
# https://github.com/GoogleCloudPlatform/cloud-builders
# https://console.cloud.google.com/gcr/images/k8s-skaffold
# Cloud Build built-in substitutions
# https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#using_default_substitutions
# gcloud deploy for Cloud Run
# https://cloud.google.com/sdk/gcloud/reference/run/deploy
# M = megabyte, Mi = mebibyte, G = gigabyte, Gi = gibibyte
# https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--memory
steps:
- id: "Build container image"
name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', '${_IMAGE}', '.']
- id: "Push container image to Artifact Registry"
name: 'gcr.io/cloud-builders/docker'
args: ['push', '${_IMAGE}']
- id: "Deploy to Cloud Run"
name: gcr.io/cloud-builders/gcloud:${_GCLOUD_VERSION}
entrypoint: /bin/bash
args:
- -c
- |
gcloud beta run deploy ${_SERVICE_NAME} \
--allow-unauthenticated \
--image ${_IMAGE} \
--memory 256M \
--min-instances 0 \
--max-instances 1 \
--platform managed \
--port ${_APP_PORT} \
--project ${PROJECT_ID} \
--region ${_REGION_ID} \
--service-account ${_SERVICE_ACCOUNT} \
--set-env-vars MAPBOX_ACCESS_TOKEN=${_MAPBOX_ACCESS_TOKEN},PLOTLY_API_KEY=${_PLOTLY_API_KEY},PLOTLY_USERNAME=${_PLOTLY_USERNAME} \
--timeout 15s \
--update-labels customer=personal,resource=service \
--verbosity warning
# user-defined substitutions and default values
substitutions:
_APP_PORT: "5000"
_ARTIFACT_REGISTRY_REPO_ID: cloud-run-source-deploy
_GCLOUD_VERSION: latest
_IMAGE: "${_REGION_ID}-docker.pkg.dev/${PROJECT_ID}/${_ARTIFACT_REGISTRY_REPO_ID}/${_IMAGE_NAME}:${_IMAGE_TAG}"
_IMAGE_NAME: dash-earthquakes
_IMAGE_TAG: latest
_REGION_ID: europe-west3
_SERVICE_ACCOUNT: sa-dash-earthquakes@prj-kitchen-sink.iam.gserviceaccount.com
_SERVICE_NAME: dash-earthquakes-production
options:
# https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values#dynamic_substitutions
dynamic_substitutions: true