-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
39 lines (29 loc) · 1.21 KB
/
Copy pathdeploy.sh
File metadata and controls
39 lines (29 loc) · 1.21 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
#!/usr/bin/env bash
# Deploy p2p-tic-tac-toe to Google Cloud Run
# ==== USER CONFIGURATION ==== #
# Replace the values below with your own GCP project details
PROJECT_ID="studio-7817843196-28639" # e.g. my-awesome-project
REGION="us-central1" # Cloud Run region
SERVICE_NAME="p2p-tic-tac-toe" # Desired Cloud Run service name
# =========================== #
# Image name (will be pushed to Container Registry)
IMAGE_NAME="gcr.io/${PROJECT_ID}/${SERVICE_NAME}:latest"
# Authenticate with Google Cloud (opens a browser for login)
gcloud auth login
gcloud config set project "$PROJECT_ID"
# Enable required APIs (run once)
gcloud services enable run.googleapis.com containerregistry.googleapis.com
# Build the Docker image
docker build -t "$IMAGE_NAME" .
# Push the image to Container Registry
docker push "$IMAGE_NAME"
# Deploy to Cloud Run (allow unauthenticated access)
gcloud run deploy "$SERVICE_NAME" \
--image "$IMAGE_NAME" \
--platform managed \
--region "$REGION" \
--allow-unauthenticated \
--port 3000
# Show the service URL
SERVICE_URL=$(gcloud run services describe "$SERVICE_NAME" --region "$REGION" --format "value(status.url)")
echo "\nDeployment complete! Service URL: $SERVICE_URL"