-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
69 lines (64 loc) · 2.33 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
65
66
67
68
69
steps:
# Step 1: Build and push Docker image to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/music-recommender:$COMMIT_SHA', '--push', '.']
env:
- 'PROJECT_ID=$PROJECT_ID'
- 'MODEL_NAME=${_MODEL_NAME}'
- 'ENDPOINT_NAME=${_ENDPOINT_NAME}'
- 'REGION=${_REGION}'
- 'SERVICE_NAME=${_SERVICE_NAME}'
# Step 2: Deploy the Docker image to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: gcloud
args:
- 'run'
- 'deploy'
- 'music-recommender'
- '--image'
- 'gcr.io/$PROJECT_ID/music-recommender:$COMMIT_SHA'
- '--region'
- '${_REGION}'
- '--platform'
- 'managed'
# Step 3: Deploy Vertex AI Pipeline
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: /bin/bash
args:
- '-c'
- |
python deployment/deploy_pipeline.py --platform vertex --project_id $PROJECT_ID --region ${_REGION} --output_file pipeline.yaml
env:
- 'MODEL_NAME=${_MODEL_NAME}'
- 'ENDPOINT_NAME=${_ENDPOINT_NAME}'
- 'REGION=${_REGION}'
- 'SERVICE_NAME=${_SERVICE_NAME}'
- 'STORAGE_BUCKET=${_STORAGE_BUCKET}'
- 'PIPELINE_NAME=${_PIPELINE_NAME}'
# Step 4: Trigger model retraining if needed (Vertex AI monitoring and retraining)
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: /bin/bash
args:
- '-c'
- |
python vertex_ai_monitoring.py --project_id $PROJECT_ID --model_name ${_MODEL_NAME} --gcs_input 'gs://$STORAGE_BUCKET/data/' --pipeline_name ${_PIPELINE_NAME} --notification_channel ${_NOTIFICATION_CHANNEL}
env:
- 'PROJECT_ID=$PROJECT_ID'
- 'MODEL_NAME=${_MODEL_NAME}'
- 'ENDPOINT_NAME=${_ENDPOINT_NAME}'
- 'REGION=${_REGION}'
- 'STORAGE_BUCKET=${_STORAGE_BUCKET}'
- 'TRIGGER_ID=${_TRIGGER_ID}'
- 'NOTIFICATION_CHANNEL=${_NOTIFICATION_CHANNEL}'
substitutions:
_PROJECT_ID: 'your-project-id'
_MODEL_NAME: 'your-model-name'
_ENDPOINT_NAME: 'your-endpoint-name'
_REGION: 'us-central1'
_SERVICE_NAME: 'your-cloud-run-service'
_STORAGE_BUCKET: 'your-storage-bucket'
_TRIGGER_ID: 'your-cloud-build-trigger-id'
_NOTIFICATION_CHANNEL: 'your-notification-channel-id'
_PIPELINE_NAME: 'your-pipeline-name'
_CANARY_TRAFFIC_PERCENT: '10'
logsBucket: gs://$PROJECT_ID-cloudbuild-logs