-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
executable file
·50 lines (48 loc) · 1.59 KB
/
cloudbuild.yaml
File metadata and controls
executable file
·50 lines (48 loc) · 1.59 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
steps:
- id: "Build container image for D2-SITE: $SHORT_SHA"
name: "gcr.io/cloud-builders/docker"
args:
- build
- -f
- k8s-docker/Dockerfile
- -t
- us.gcr.io/backend-restful-api/d2-site:$SHORT_SHA
- .
timeout: 3000s
- id: "Register the container image"
name: "gcr.io/cloud-builders/docker"
args:
- push
- us.gcr.io/backend-restful-api/d2-site:$SHORT_SHA
- id: "List and remove past images"
name: "gcr.io/cloud-builders/gcloud"
entrypoint: "bash"
args:
- "-c"
- |
# List all tags for the "d2-site" image
tags=$(gcloud container images list-tags us.gcr.io/backend-restful-api/d2-site --format='get(tags)')
# Keep only the three latest tags
keep_tags=$(echo "$tags" | head -n 3)
# Remove all tags except the three latest ones
echo "$tags" | grep -v "$keep_tags" | xargs -I{} gcloud container images delete us.gcr.io/backend-restful-api/d2-site:{}
# fix env substituition
- id: "Pre-process kubernetes configuration for D2-SITE"
name: gcr.io/backend-restful-api/envsubst
env: ["SHORT_SHA=$SHORT_SHA"]
args: ["k8s/deployment-d2-site.yaml"]
# deploy container image to GKE
# deploy D2-SITE
- id: "Deploying to cluster D2-SITE"
name: "gcr.io/cloud-builders/gke-deploy"
timeout: 3200s
args:
- run
- --image=us.gcr.io/backend-restful-api/d2-site:$SHORT_SHA
- --filename=k8s/
- --project=backend-restful-api
- --location=europe-west2-c
- --cluster=cluster-1
- --timeout=25m
- --output="./outputwo"
timeout: 6900s