-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudbuild.api.yaml
53 lines (48 loc) · 1.19 KB
/
cloudbuild.api.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
steps:
- id: 'install'
name: 'python:3.11.4'
entrypoint: pip
args: ['install', '-r', 'requirements.txt', '--user', '--no-warn-script-location']
waitFor: ['-']
- id: 'test'
name: 'python:3.11.4'
entrypoint: python
args: ['-m', 'pytest', 'api']
waitFor: ['install']
- id: 'pull'
name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker pull ${_IMAGE_URL}:latest || exit 0']
waitFor: ['test']
- id: 'build'
name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-t',
'${_IMAGE_URL}:${_IMAGE_TAG}',
'--cache-from',
'${_IMAGE_URL}:latest',
'-f',
'api/Dockerfile',
'.'
]
waitFor: ['test', 'pull']
- id: 'tag'
name: 'gcr.io/cloud-builders/docker'
args: [
'tag',
'${_IMAGE_URL}:${_IMAGE_TAG}',
'${_IMAGE_URL}:latest'
]
waitFor: ['build']
images:
- '${_IMAGE_URL}:${_IMAGE_TAG}'
- '${_IMAGE_URL}:latest'
substitutions:
_DOCKER_REGISTRY: 'europe-west3-docker.pkg.dev'
_IMAGE_NAME: 'chartgpt-api'
_IMAGE_URL: '${_DOCKER_REGISTRY}/${PROJECT_ID}/${PROJECT_ID}/${_IMAGE_NAME}'
# NOTE: SHORT_SHA is only available in the Google Cloud Build environment
_IMAGE_TAG: '${SHORT_SHA}'
options:
dynamicSubstitutions: true