22
33This guide covers deploying Jemmie to Google Cloud Run.
44
5- ---
6-
75## Prerequisites
86
97- Google Cloud account with billing enabled
108- ` gcloud ` CLI installed and authenticated
119- Project ID noted
1210
13- ---
14-
1511## One-Time Infrastructure Setup
1612
17- Run the setup script to enable APIs, create Artifact Registry, and configure Firestore:
13+ Run the setup script to enable APIs, create Artifact Registry, and configure Firestore.
1814
1915``` bash
2016export PROJECT_ID=" your-project-id"
17+ export REGION=us-central1
2118./scripts/setup_infra.sh $PROJECT_ID
2219```
2320
2421This enables:
22+
2523- Cloud Run API
2624- Artifact Registry API
2725- Cloud Build API
@@ -30,8 +28,6 @@ This enables:
3028
3129And grants Vertex AI permissions to the Cloud Run service account.
3230
33- ---
34-
3531## GitHub Actions Setup
3632
3733### 1. Create Service Account
@@ -65,14 +61,11 @@ rm key.json
6561### 3. Add GitHub Secrets
6662
6763Navigate to your repository: ** Settings → Secrets and variables → Actions**
68-
6964| Secret | Value |
7065| --------| -------|
7166| ` GCP_PROJECT_ID ` | Your GCP project ID |
7267| ` GCP_SERVICE_ACCOUNT_KEY ` | Base64 output from step 2 |
7368
74- ---
75-
7669## Deploy
7770
7871Push to main branch:
@@ -82,45 +75,41 @@ git push origin main
8275```
8376
8477The CI pipeline will:
78+
85791 . Run lint, type check, and tests
86802 . Build Docker image (production target)
87813 . Push to Artifact Registry
88824 . Deploy to Cloud Run
8983
90- ---
91-
9284## Cloud Run Configuration
9385
94- | Setting | Value | Purpose |
95- | ---------| -------| ---------|
96- | Session affinity | Enabled | Keeps reconnects on same instance |
97- | Timeout | 3600s | Long-lived WebSocket connections |
98- | Min instances | 1 | Prevents cold start |
99- | Authentication | Unauthenticated | Device-as-identity model |
100-
101- ---
86+ | Setting | Value | Purpose |
87+ | ------------------| -----------------| -----------------------------------|
88+ | Session affinity | Enabled | Keeps reconnects on same instance |
89+ | Timeout | 3600s | Long-lived WebSocket connections |
90+ | Min instances | 1 | Prevent cold start |
91+ | Authentication | Unauthenticated | Device-as-identity model |
10292
10393## Verification
10494
10595After deployment:
10696
10797``` bash
10898SERVICE_URL=$( gcloud run services describe jemmie-backend \
109- --region=asia-southeast1 \
99+ --region=us-central1 \
110100 --format=' value(status.url)' )
111101
112102curl $SERVICE_URL /health
113103```
114104
115105WebSocket endpoint: ` wss://{service-url}/ws/{device_id} `
116106
117- ---
118-
119107## Troubleshooting
120108
121109### Deployment fails with permission error
122110
123111Ensure the service account has all required roles:
112+
124113``` bash
125114gcloud projects get-iam-policy $PROJECT_ID \
126115 --flatten=" bindings[].members" \
@@ -130,6 +119,7 @@ gcloud projects get-iam-policy $PROJECT_ID \
130119### Cloud Run returns 403 on Vertex AI calls
131120
132121Grant Vertex AI permissions to the Cloud Run service account:
122+
133123``` bash
134124PROJECT_NUMBER=$( gcloud projects describe $PROJECT_ID --format=' value(projectNumber)' )
135125gcloud projects add-iam-policy-binding $PROJECT_ID \
@@ -140,6 +130,7 @@ gcloud projects add-iam-policy-binding $PROJECT_ID \
140130### WebSocket connections drop
141131
142132Check Cloud Run timeout and session affinity settings:
133+
143134``` bash
144135gcloud run services describe jemmie-backend \
145136 --region=us-central1 \
0 commit comments