forked from cloudfoundry-samples/spring-music
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
47 lines (39 loc) · 1.59 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
steps:
# Clone the GitHub repository
- name: 'gcr.io/cloud-builders/git'
args: ['clone', 'https://github.com/Nuvalence/spring-music.git']
dir: '/workspace'
# Run Gradle build without tests using JDK 17
- name: 'gradle:7.4.1-jdk17'
args: ['gradle', 'clean', 'build', '-x', 'test']
dir: '/workspace/spring-music'
# Run Gradle tests using JDK 17
- name: 'gradle:7.4.1-jdk17'
args: ['gradle', 'test']
dir: '/workspace/spring-music'
id: 'run-tests'
# Build the Docker image
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'us-central1-docker.pkg.dev/cloudbridge-dev-402414/development/spring-music:$SHORT_SHA', '.']
dir: '/workspace/spring-music'
id: 'build-docker-image'
# Push the Docker image to Artifact Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'us-central1-docker.pkg.dev/cloudbridge-dev-402414/development/spring-music:$SHORT_SHA']
id: 'push-docker-image'
# Deploy to GKE
- name: 'gcr.io/cloud-builders/gke-deploy'
args: ['run', '--image=us-central1-docker.pkg.dev/cloudbridge-dev-402414/development/spring-music:$SHORT_SHA', '--location=us-central1', '--cluster=jcsm-cluster-1']
id: 'deploy-to-gke'
# List of images to be pushed to Artifact Registry
images:
- 'us-central1-docker.pkg.dev/cloudbridge-dev-402414/development/spring-music:$SHORT_SHA'
# Build timeout setting
timeout: '1600s'
# Machine type and environment variables for the build
options:
machineType: 'N1_HIGHCPU_8'
diskSizeGb: '100'
env:
- 'CLOUDSDK_COMPUTE_REGION=us-central1'
- 'CLOUDSDK_CONTAINER_CLUSTER=jcsm-cluster-1'