-
Notifications
You must be signed in to change notification settings - Fork 90
/
cloudbuild.yaml
64 lines (55 loc) · 2 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
56
57
58
59
60
61
62
63
64
steps:
# Step 1: Access the service account key from Secret Manager
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud secrets versions access latest --secret=ead8dc959ea862a93ac752d32753373eae458033 > /key.json
# Step 2: Authenticate Docker with your service account key and configure Docker credentials
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud auth activate-service-account --key-file=/key.json
gcloud config set project ${PROJECT_ID}
gcloud auth configure-docker
# Step 3: Set up Docker Buildx
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'create', '--name', 'mybuilder']
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'use', 'mybuilder']
- name: 'gcr.io/cloud-builders/docker'
args: ['buildx', 'inspect', '--bootstrap']
# Step 4: Build and push worker-cli image to GCR with multiple tags
- name: 'gcr.io/cloud-builders/docker'
id: Build and push worker-cli image to GCR
args:
[
'buildx', 'build', '.',
'--platform', 'linux/amd64,linux/arm64',
'--tag', 'gcr.io/${PROJECT_ID}/${_IMAGE_NAME}:amd64-${_TAG}',
'--tag', 'gcr.io/${PROJECT_ID}/${_IMAGE_NAME}:arm64-${_TAG}',
'--tag', 'gcr.io/${PROJECT_ID}/${_IMAGE_NAME}:${_TAG}',
'--push',
'--file', 'docker/docker/worker-cli/Dockerfile'
]
# Optional Step 5: Save the key to a specified location (like a Cloud Storage bucket)
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gsutil cp /key.json gs://betterscan/
images:
- 'gcr.io/${PROJECT_ID}/${_IMAGE_NAME}:${_TAG}'
- 'gcr.io/${PROJECT_ID}/${_IMAGE_NAME}:amd64-${_TAG}'
- 'gcr.io/${PROJECT_ID}/${_IMAGE_NAME}:arm64-${_TAG}'
options:
defaultLogsBucketBehavior: 'REGIONAL_USER_OWNED_BUCKET'
substitutions:
_PAT: ''
_DOCKER_USERNAME: ''
_IMAGE_NAME: 'betterscan-worker-cli'
_TAG: 'latest'