-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
181 lines (160 loc) · 7.04 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
steps:
- name: "node"
entrypoint: "npm"
args: ["install", "-g", "pnpm"]
# Install dependencies
- name: "node"
entrypoint: "pnpm"
args: ["install"]
# Build turbo
- name: "node"
entrypoint: "pnpm"
args: ["run", "build"]
# Build server Docker image
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/server", "./apps/server"]
# Push server Docker image
- name: "gcr.io/cloud-builders/docker"
args: ["push", "gcr.io/$PROJECT_ID/server"]
# Build nextjs Docker image
- name: "gcr.io/cloud-builders/docker"
args: ["build", "-t", "gcr.io/$PROJECT_ID/nextjs", "./apps/nextjs"]
# Push nextjs Docker image
- name: "gcr.io/cloud-builders/docker"
args: ["push", "gcr.io/$PROJECT_ID/nextjs"]
# Deploy server to Cloud Run
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: "gcloud"
args:
[
"run",
"deploy",
"server",
"--image",
"gcr.io/$PROJECT_ID/server",
"--region",
"us-central1",
"--platform",
"managed",
]
# Deploy nextjs to Cloud Run
- name: "gcr.io/google.com/cloudsdktool/cloud-sdk"
entrypoint: "gcloud"
args:
[
"run",
"deploy",
"nextjs",
"--image",
"gcr.io/$PROJECT_ID/nextjs",
"--region",
"us-central1",
"--platform",
"managed",
]
# substitutions:
# _SERVICE_NAME: 'aiboo'
# _REPOSITORY: 'github.com/dar0xt'
# _REGION: 'asia-northeast1'
# # Environment variables
# _WEB_BASE_URL: "https://aiboo-web-dev-afxyr7jnaa-an.a.run.app"
# _API_BASE_URL: "https://aiboo-api-dev-afxyr7jnaa-an.a.run.app"
# _SANDBOX_API_BASE_URL: "https://aiboo-sandbox-api-dev-afxyr7jnaa-an.a.run.app"
# _SUPABASE_URL: 'https://lkrzyevgztqrbxyhzdnh.supabase.co'
# _SUPABASE_ANON_KEY: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Imxrcnp5ZXZnenRxcmJ4eWh6ZG5oIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTM4NDI4NTgsImV4cCI6MjAyOTQxODg1OH0.Rxzmd8n_DVXjD4AgvaMsRocTBSNyxlVG6Yznk6mBuhM"
# _STRIPE_PUBLISHABLE_KEY: "pk_test_51PE47rAtCCNlxvJHAtcnrPKjcIMloCL7SUHrCpK9tb2o9HBJKsJic7MTpvqgYLHewfSAMJDZRAo21ESaYOCDMdF9000M2odvRn"
# _WEB_SERVICE_NAME: '${_SERVICE_NAME}-web-dev'
# _API_SERVICE_NAME: '${_SERVICE_NAME}-api-dev'
# _SANDBOX_API_SERVICE_NAME: '${_SERVICE_NAME}-sandbox-api-dev'
# _WEB_DOCKER_FILE_PATH: './Dockerfile.web'
# _API_DOCKER_FILE_PATH: './Dockerfile.api'
# _SANDBOX_API_DOCKER_FILE_PATH: './Dockerfile.sandbox-api'
# _WEB_IMAGE_TAG_NAME: 'gcr.io/${PROJECT_ID}/${_SERVICE_NAME}-web:${BUILD_ID}'
# _API_IMAGE_TAG_NAME: 'gcr.io/${PROJECT_ID}/${_SERVICE_NAME}-api:${BUILD_ID}'
# _SANDBOX_API_IMAGE_TAG_NAME: 'gcr.io/${PROJECT_ID}/${_SERVICE_NAME}sandbox-api:${BUILD_ID}'
# steps:
# # Api
# # Build the container image
# - name: gcr.io/cloud-builders/docker
# secretEnv: [
# 'DATABASE_URL',
# 'DIRECT_URL',
# 'ANTHROPIC_API_KEY',
# 'STRIPE_SECRET_KEY',
# 'STRIPE_WEBHOOK_SECRET'
# ]
# entrypoint: bash
# args: [
# '-c',
# 'docker build -t ${_API_IMAGE_TAG_NAME} -f ${_API_DOCKER_FILE_PATH} --build-arg DIRECT_URL="$$DIRECT_URL" --build-arg DATABASE_URL="$$DATABASE_URL" --build-arg ANTHROPIC_API_KEY="$$ANTHROPIC_API_KEY" --build-arg STRIPE_SECRET_KEY="$$STRIPE_SECRET_KEY" --build-arg STRIPE_WEBHOOK_SECRET="$$STRIPE_WEBHOOK_SECRET" --build-arg API_BASE_URL=${_API_BASE_URL} --build-arg WEB_BASE_URL=${_WEB_BASE_URL} --build-arg SUPABASE_URL=${_SUPABASE_URL} --build-arg SUPABASE_ANON_KEY=${_SUPABASE_ANON_KEY} --build-arg STRIPE_PUBLISHABLE_KEY=${_STRIPE_PUBLISHABLE_KEY} .'
# ]
# # Push the container image to Container Registry
# - name: 'gcr.io/cloud-builders/docker'
# args: ['push', '${_API_IMAGE_TAG_NAME}']
# # Deploy container image to Cloud Run
# - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
# entrypoint: bash
# args: [
# '-c',
# 'gcloud run deploy ${_API_SERVICE_NAME} --image ${_API_IMAGE_TAG_NAME} --platform managed --region ${_REGION} --allow-unauthenticated --port 8080'
# ]
# # Sandbox Api
# # Build the container image
# - name: gcr.io/cloud-builders/docker
# secretEnv: [
# 'DATABASE_URL',
# 'DIRECT_URL',
# 'ANTHROPIC_API_KEY',
# 'STRIPE_SECRET_KEY',
# 'STRIPE_WEBHOOK_SECRET'
# ]
# entrypoint: bash
# args: [
# '-c',
# 'docker build -t ${_API_IMAGE_TAG_NAME} -f ${_API_DOCKER_FILE_PATH} --build-arg DIRECT_URL="$$DIRECT_URL" --build-arg DATABASE_URL="$$DATABASE_URL" --build-arg ANTHROPIC_API_KEY="$$ANTHROPIC_API_KEY" --build-arg STRIPE_SECRET_KEY="$$STRIPE_SECRET_KEY" --build-arg STRIPE_WEBHOOK_SECRET="$$STRIPE_WEBHOOK_SECRET" --build-arg API_BASE_URL=${_API_BASE_URL} --build-arg WEB_BASE_URL=${_WEB_BASE_URL} --build-arg SUPABASE_URL=${_SUPABASE_URL} --build-arg SUPABASE_ANON_KEY=${_SUPABASE_ANON_KEY} --build-arg STRIPE_PUBLISHABLE_KEY=${_STRIPE_PUBLISHABLE_KEY} .'
# ]
# # Push the container image to Container Registry
# - name: 'gcr.io/cloud-builders/docker'
# args: ['push', '${_API_IMAGE_TAG_NAME}']
# # Deploy container image to Cloud Run
# - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
# entrypoint: bash
# args: [
# '-c',
# 'gcloud run deploy ${_API_SERVICE_NAME} --image ${_API_IMAGE_TAG_NAME} --platform managed --region ${_REGION} --allow-unauthenticated --port 8080'
# ]
# # Web
# # Build the container image
# - name: gcr.io/cloud-builders/docker
# secretEnv: ['DATABASE_URL', 'DIRECT_URL']
# entrypoint: bash
# args: [
# '-c',
# 'docker build -t ${_WEB_IMAGE_TAG_NAME} -f ${_WEB_DOCKER_FILE_PATH} --build-arg NEXT_PUBLIC_API_BASE_URL=${_API_BASE_URL} --build-arg NEXT_PUBLIC_WEB_BASE_URL=${_WEB_BASE_URL} --build-arg NEXT_PUBLIC_SUPABASE_URL=${_SUPABASE_URL} --build-arg NEXT_PUBLIC_SUPABASE_ANON_KEY=${_SUPABASE_ANON_KEY} --build-arg NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=${_STRIPE_PUBLISHABLE_KEY} .'
# ]
# # Push the container image to Container Registry
# - name: 'gcr.io/cloud-builders/docker'
# args: ['push', '${_WEB_IMAGE_TAG_NAME}']
# # Deploy container image to Cloud Run
# - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
# entrypoint: bash
# args: [
# '-c',
# 'gcloud run deploy ${_WEB_SERVICE_NAME} --image ${_WEB_IMAGE_TAG_NAME} --platform managed --region ${_REGION} --allow-unauthenticated --port 8080'
# ]
# images:
# - '${_WEB_IMAGE_TAG_NAME}'
# - '${_API_IMAGE_TAG_NAME}'
# - '${_SANDBOX_API_IMAGE_TAG_NAME}'
# availableSecrets:
# secretManager:
# - versionName: projects/649078383779/secrets/DATABASE_URL/versions/latest
# env: 'DATABASE_URL'
# - versionName: projects/649078383779/secrets/DIRECT_URL/versions/latest
# env: 'DIRECT_URL'
# - versionName: projects/649078383779/secrets/ANTHROPIC_API_KEY/versions/latest
# env: 'ANTHROPIC_API_KEY'
# - versionName: projects/649078383779/secrets/STRIPE_SECRET_KEY/versions/latest
# env: 'STRIPE_SECRET_KEY'
# - versionName: projects/649078383779/secrets/STRIPE_WEBHOOK_SECRET/versions/latest
# env: 'STRIPE_WEBHOOK_SECRET'