Repository navigation
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
80 lines (72 loc) · 2.75 KB
/
Copy pathcloudbuild.yaml
File metadata and controls
80 lines (72 loc) · 2.75 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
# ─────────────────────────────────────────────────────────────────────────────
# LEGACY — retired; see the maintainer runbook.
# Redstring now ships via Cloudflare Pages. This Cloud Build config deploys a
# public (--allow-unauthenticated) Cloud Run service. Its first step fails
# unless the build is submitted with --substitutions=_ALLOW_LEGACY_GCP=1.
# ─────────────────────────────────────────────────────────────────────────────
# Google Cloud Build Configuration for Redstring UI React
# Builds and deploys to Cloud Run
steps:
# Refuse to run unless explicitly opted in (retired infrastructure).
- name: 'bash'
entrypoint: 'bash'
args: ['-c', 'if [ "$_ALLOW_LEGACY_GCP" != "1" ]; then echo "Refusing: retired GCP deployment. See the maintainer runbook" >&2; exit 1; fi']
id: 'legacy-guard'
# Step 1: Build Docker image
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '-f'
- 'deployment/docker/Dockerfile'
- '-t'
- 'gcr.io/$PROJECT_ID/redstring-app:$BUILD_ID'
- '-t'
- 'gcr.io/$PROJECT_ID/redstring-app:latest'
- '.'
id: 'build-image'
# Step 2: Push to Container Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/redstring-app:$BUILD_ID']
id: 'push-image'
waitFor: ['build-image']
# Step 3: Deploy to Cloud Run (Production)
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
entrypoint: 'gcloud'
args:
- 'run'
- 'deploy'
- 'your-service-name'
- '--image'
- 'gcr.io/$PROJECT_ID/redstring-app:$BUILD_ID'
- '--region'
- '${_REGION}'
- '--platform'
- 'managed'
- '--allow-unauthenticated'
- '--port'
- '4000'
- '--memory'
- '1Gi'
- '--cpu'
- '2'
- '--concurrency'
- '100'
- '--max-instances'
- '10'
- '--set-env-vars'
- 'NODE_ENV=production,OAUTH_PORT=3002,LOG_LEVEL=warn'
- '--set-secrets'
- 'GITHUB_CLIENT_ID=github-client-id:latest,GITHUB_CLIENT_SECRET=github-client-secret:latest,VITE_GITHUB_CLIENT_ID=github-client-id:latest'
id: 'deploy-prod'
waitFor: ['push-image']
# Substitution variables (set these in Cloud Build trigger)
substitutions:
_ALLOW_LEGACY_GCP: '0'
_REGION: 'us-central1'
# Build timeout
timeout: '1200s'
# Log to Cloud Logging
logsBucket: 'gs://${PROJECT_ID}-build-logs'
images:
- 'gcr.io/$PROJECT_ID/redstring-app:$BUILD_ID'
- 'gcr.io/$PROJECT_ID/redstring-app:latest'