Skip to content

Commit 702208a

Browse files
Iman CrooksIman Crooks
Iman Crooks
authored and
Iman Crooks
committed
adding the cloudbuild.yml
1 parent 359146a commit 702208a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

cloudbuild.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
steps:
2+
# Step 1: Build Docker Image
3+
- name: 'gcr.io/cloud-builders/docker'
4+
args: ['build', '-t', 'gcr.io/$PROJECT_ID/my-app:latest', '.']
5+
6+
# Step 2: Push Docker Image to Container Registry
7+
- name: 'gcr.io/cloud-builders/docker'
8+
args: ['push', 'gcr.io/$PROJECT_ID/my-app:latest']
9+
10+
# Step 3: Run Unit Tests
11+
- name: 'python'
12+
entrypoint: 'bash'
13+
args:
14+
- '-c'
15+
- |
16+
pip install -r requirements.txt
17+
pytest tests/
18+
19+
# Step 4: Scan Docker Image with Trivy
20+
- name: 'aquasec/trivy'
21+
args: ['image', '--exit-code', '1', 'gcr.io/$PROJECT_ID/my-app:latest']
22+
23+
# Step 5: Snyk Code and Dependency Scanning
24+
- name: 'node'
25+
entrypoint: 'bash'
26+
args:
27+
- '-c'
28+
- |
29+
npm install -g snyk
30+
snyk auth $SNYK_TOKEN
31+
snyk test
32+
snyk code test
33+
34+
# Step 6: Deploy to Cloud Run
35+
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
36+
entrypoint: 'bash'
37+
args:
38+
- '-c'
39+
- |
40+
gcloud run deploy my-service \
41+
--image gcr.io/$PROJECT_ID/my-app:latest \
42+
--region us-central1 \
43+
--platform managed

0 commit comments

Comments
 (0)