-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
81 lines (72 loc) · 2.54 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
81 lines (72 loc) · 2.54 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
steps:
# Build backend
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-f', 'backend/Dockerfile.cloudrun',
'-t', 'gcr.io/$PROJECT_ID/posting-app-backend:$COMMIT_SHA',
'-t', 'gcr.io/$PROJECT_ID/posting-app-backend:latest',
'./backend'
]
# Build frontend
- name: 'gcr.io/cloud-builders/docker'
args: [
'build',
'-f', 'front/Dockerfile.cloudrun',
'-t', 'gcr.io/$PROJECT_ID/posting-app-frontend:$COMMIT_SHA',
'-t', 'gcr.io/$PROJECT_ID/posting-app-frontend:latest',
'./front'
]
# Push backend image
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/posting-app-backend:$COMMIT_SHA']
# Push frontend image
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/posting-app-frontend:$COMMIT_SHA']
# Deploy backend to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'gcloud'
args: [
'run', 'deploy', 'posting-app-backend',
'--image', 'gcr.io/$PROJECT_ID/posting-app-backend:$COMMIT_SHA',
'--region', 'us-central1',
'--platform', 'managed',
'--allow-unauthenticated',
'--set-env-vars', 'DB_HOST=${_DB_HOST},DB_USER=${_DB_USER},DB_PASSWORD=${_DB_PASSWORD},DB_NAME=${_DB_NAME},JWT_SECRET=${_JWT_SECRET},STRIPE_API_KEY=${_STRIPE_API_KEY},STRIPE_PRICE_ID=${_STRIPE_PRICE_ID},STRIPE_WEBHOOK_SECRET=${_STRIPE_WEBHOOK_SECRET}',
'--memory', '512Mi',
'--cpu', '1',
'--concurrency', '100',
'--max-instances', '10'
]
# Deploy frontend to Cloud Run
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'gcloud'
args: [
'run', 'deploy', 'posting-app-frontend',
'--image', 'gcr.io/$PROJECT_ID/posting-app-frontend:$COMMIT_SHA',
'--region', 'us-central1',
'--platform', 'managed',
'--allow-unauthenticated',
'--memory', '256Mi',
'--cpu', '1',
'--concurrency', '80',
'--max-instances', '5'
]
# Store images in Container Registry
images:
- 'gcr.io/$PROJECT_ID/posting-app-backend:$COMMIT_SHA'
- 'gcr.io/$PROJECT_ID/posting-app-frontend:$COMMIT_SHA'
# Substitution variables (set these in Cloud Build trigger)
substitutions:
_DB_HOST: 'your-db-host'
_DB_USER: 'your-db-user'
_DB_PASSWORD: 'your-db-password'
_DB_NAME: 'posting_app'
_JWT_SECRET: 'your-jwt-secret'
_STRIPE_API_KEY: 'your-stripe-api-key'
_STRIPE_PRICE_ID: 'your-stripe-price-id'
_STRIPE_WEBHOOK_SECRET: 'your-stripe-webhook-secret'
options:
machineType: 'E2_HIGHCPU_8'
diskSizeGb: 100
timeout: '1200s'