-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdeploy_cloudrun.sh
More file actions
executable file
·76 lines (66 loc) · 2.12 KB
/
deploy_cloudrun.sh
File metadata and controls
executable file
·76 lines (66 loc) · 2.12 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
#!/bin/bash
# ADK SQL Agent - Cloud Run Deployment Script
# Alternative deployment using Google Cloud Run
set -e
# Configuration
PROJECT_ID="your-project"
REGION="${GOOGLE_CLOUD_LOCATION:-us-central1}"
SERVICE_NAME="adk-sql-agent"
REPO_LOCATION="us" # same as you used when creating the repo
REPO_NAME="adk-sql-agent-repo"
IMAGE_NAME="${REPO_LOCATION}-docker.pkg.dev/${PROJECT_ID}/${REPO_NAME}/${SERVICE_NAME}"
#IMAGE_NAME="gcr.io/${PROJECT_ID}/${SERVICE_NAME}"
echo "🚀 Deploying ADK SQL Agent to Cloud Run"
echo "Project: $PROJECT_ID"
echo "Region: $REGION"
echo ""
# Step 1: Enable required APIs
echo "📦 Enabling required APIs..."
~/google-cloud-sdk/bin/gcloud services enable \
run.googleapis.com \
cloudbuild.googleapis.com \
containerregistry.googleapis.com \
aiplatform.googleapis.com \
--project=$PROJECT_ID
# Step 2: Build the container image
echo "🏗️ Building container image..."
~/google-cloud-sdk/bin/gcloud builds submit \
--tag $IMAGE_NAME \
--project=$PROJECT_ID
# Step 3: Deploy to Cloud Run
echo "🚢 Deploying to Cloud Run..."
~/google-cloud-sdk/bin/gcloud run deploy $SERVICE_NAME \
--image $IMAGE_NAME \
--platform managed \
--region $REGION \
--allow-unauthenticated \
--set-env-vars GOOGLE_GENAI_USE_VERTEXAI=TRUE \
--set-env-vars GOOGLE_CLOUD_PROJECT=$PROJECT_ID \
--set-env-vars GOOGLE_CLOUD_LOCATION=$REGION \
--memory 4Gi \
--cpu 2 \
--min-instances 1 \
--max-instances 10 \
--timeout 300 \
--project=$PROJECT_ID
# Get the service URL
SERVICE_URL=$(~/google-cloud-sdk/bin/gcloud run services describe $SERVICE_NAME \
--platform managed \
--region $REGION \
--project=$PROJECT_ID \
--format='value(status.url)')
echo ""
echo "✅ Deployment complete!"
echo ""
echo "Service URL: $SERVICE_URL"
echo ""
echo "To test your service:"
echo " curl $SERVICE_URL/status"
echo ""
echo "To send a query:"
echo " curl -X POST $SERVICE_URL/query \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"query\": \"Show me the top 10 authors by sales\"}'"
echo ""
echo "To view logs:"
echo "gcloud run services logs read $SERVICE_NAME --project=$PROJECT_ID --region=$REGION"