File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,13 +7,28 @@ source ../../.env
77
88ENV=${1:- prod}
99
10+ if [ " $ENV " != " prod" ] && [ " $ENV " != " dev" ]; then
11+ echo " Invalid environment '${ENV} '; must be 'dev' or 'prod'."
12+ exit 1
13+ fi
14+
1015# Config
1116REGION=" us-west1"
1217ZONE=" us-west1-b"
1318
14- PROJECT=" compass-130ba"
19+ # Prod and dev live in separate GCP/Firebase projects (see main.tf). The image is
20+ # built into, and Cloud Run deployed to, the project matching $ENV.
21+ if [ " $ENV " = " prod" ]; then
22+ PROJECT=" compass-130ba"
23+ DOMAIN=" api.compassmeet.com"
24+ else
25+ PROJECT=" compass-57c3c"
26+ DOMAIN=" api.dev.compassmeet.com"
27+ fi
1528SERVICE_NAME=" api"
1629
30+ echo " Deploying '${SERVICE_NAME} ' to ${ENV} (project ${PROJECT} )"
31+
1732GIT_REVISION=$( git rev-parse --short HEAD)
1833GIT_COMMIT_DATE=$( git log -1 --format=%ci)
1934GIT_COMMIT_AUTHOR=$( git log -1 --format=' %an' )
@@ -47,9 +62,10 @@ docker push ${IMAGE_URL}
4762# but simply swaps the container image.
4863gcloud run deploy ${SERVICE_NAME} \
4964 --image ${IMAGE_URL} \
65+ --project ${PROJECT} \
5066 --region ${REGION} \
5167 --platform managed \
5268 --quiet
5369
54- echo " Custom Domain: https://api.compassmeet.com "
70+ echo " Custom Domain: https://${DOMAIN} "
5571echo " ✅ Code updated on Cloud Run!"
Original file line number Diff line number Diff line change @@ -12,12 +12,19 @@ variable "env" {
1212
1313# 2. Local Constants
1414locals {
15- project = " compass-130ba"
15+ is_prod = var. env == " prod"
16+ # Prod and dev live in separate GCP/Firebase projects. env=dev targets the dev
17+ # Firebase project so the API talks to the dev Auth/Firestore/Storage backends.
18+ project = local. is_prod ? " compass-130ba" : " compass-57c3c"
1619 region = " us-west1"
1720 service_name = " api"
21+ api_domain = local. is_prod ? " api.compassmeet.com" : " api.dev.compassmeet.com"
1822}
1923
2024# 3. Provider & Backend
25+ # State stays in the prod bucket but is isolated per environment via Terraform
26+ # workspaces (default = prod, `terraform workspace new dev` for dev). The gcs
27+ # backend automatically namespaces named workspaces, so dev/prod never collide.
2128terraform {
2229 backend "gcs" {
2330 bucket = " compass-130ba-terraform-state"
@@ -142,7 +149,7 @@ resource "google_cloud_run_v2_service_iam_member" "public_access" {
142149# Otherwise, use 'google_cloud_run_v2_domain_mapping'
143150resource "google_cloud_run_domain_mapping" "api_domain" {
144151 location = local. region
145- name = " api.compassmeet.com "
152+ name = local . api_domain
146153
147154 metadata {
148155 namespace = local. project
You can’t perform that action at this time.
0 commit comments