-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
146 lines (131 loc) · 3.52 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
146 lines (131 loc) · 3.52 KB
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
139
140
141
142
143
144
145
146
# Cloud Build Configuration
# Triggered by Cloud Build triggers or manually
substitutions:
_REGION: europe-west3
_REPOSITORY: code-challenge
_ENV: dev
steps:
# Run tests
- name: python:3.13-slim
id: test
entrypoint: bash
args:
- -c
- |
pip install -e ".[dev]" && \
pytest tests/unit -v --cov=src
# Build API image
- name: gcr.io/cloud-builders/docker
id: build-api
waitFor: [test]
args:
- build
- --platform
- linux/amd64
- -t
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/api:${SHORT_SHA}
- -t
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/api:latest
- -f
- dockerfiles/api.Dockerfile
- .
# Build ML image
- name: gcr.io/cloud-builders/docker
id: build-ml
waitFor: [test]
args:
- build
- --platform
- linux/amd64
- -t
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/ml:${SHORT_SHA}
- -t
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/ml:latest
- -f
- dockerfiles/ml.Dockerfile
- .
# Build Data image
- name: gcr.io/cloud-builders/docker
id: build-data
waitFor: [test]
args:
- build
- --platform
- linux/amd64
- -t
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/data:${SHORT_SHA}
- -t
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/data:latest
- -f
- dockerfiles/data.Dockerfile
- .
# Push images
- name: gcr.io/cloud-builders/docker
id: push-api
args: [push, --all-tags, '${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/api']
waitFor: [build-api]
- name: gcr.io/cloud-builders/docker
id: push-ml
args: [push, --all-tags, '${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/ml']
waitFor: [build-ml]
- name: gcr.io/cloud-builders/docker
id: push-data
args: [push, --all-tags, '${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/data']
waitFor: [build-data]
# Deploy API
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
id: deploy-api
entrypoint: gcloud
args:
- run
- deploy
- code-challenge-api
- --image=${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/api:${SHORT_SHA}
- --region=${_REGION}
waitFor: [push-api]
# Run smoke test
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
id: smoke-test
entrypoint: bash
args:
- -c
- |
SERVICE_URL=$(gcloud run services describe code-challenge-api \
--region=${_REGION} \
--format='value(status.url)')
curl -f "$SERVICE_URL/health" || exit 1
waitFor: [deploy-api]
# Update Cloud Run Jobs
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
id: update-training-job
entrypoint: gcloud
args:
- run
- jobs
- update
- code-challenge-training
- --region=${_REGION}
- --image=${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/ml:${SHORT_SHA}
waitFor: [push-ml]
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
id: update-data-job
entrypoint: gcloud
args:
- run
- jobs
- update
- code-challenge-data-sim
- --region=${_REGION}
- --image=${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/data:${SHORT_SHA}
waitFor: [push-data]
images:
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/api:${SHORT_SHA}
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/api:latest
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/ml:${SHORT_SHA}
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/ml:latest
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/data:${SHORT_SHA}
- ${_REGION}-docker.pkg.dev/${PROJECT_ID}/${_REPOSITORY}/data:latest
options:
logging: CLOUD_LOGGING_ONLY
machineType: E2_HIGHCPU_8
timeout: 1800s