-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
67 lines (58 loc) · 2.18 KB
/
deploy.sh
File metadata and controls
67 lines (58 loc) · 2.18 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
#!/bin/bash
# Cortex Deployment Script — Bash (Linux/Mac/Cloud Shell)
# Google Cloud Gen AI Academy APAC 2026 — Cohort 1 Hackathon
set -e
echo "============================================="
echo "Cortex Deployment — Cloud Run"
echo "============================================="
# Load environment variables
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
# Validate required env vars
required_vars=("PROJECT_ID" "REGION" "DB_HOST" "DB_PORT" "DB_NAME" "DB_USER" "DB_PASSWORD")
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "ERROR: $var is not set. Copy .env.example to .env and fill in values."
exit 1
fi
done
PROJECT_ID=${PROJECT_ID}
REGION=${REGION:-europe-west1}
SERVICE_NAME=cortex-agent
IMAGE_URI=gcr.io/${PROJECT_ID}/${SERVICE_NAME}:latest
echo "Project: $PROJECT_ID"
echo "Region: $REGION"
echo "Service: $SERVICE_NAME"
# Step 1: Build container image using Cloud Build
echo ""
echo "Step 1: Building Docker image..."
gcloud builds submit --tag ${IMAGE_URI} --project=${PROJECT_ID} .
# Step 2: Deploy to Cloud Run
echo ""
echo "Step 2: Deploying to Cloud Run..."
gcloud run deploy ${SERVICE_NAME} \
--image=${IMAGE_URI} \
--platform=managed \
--region=${REGION} \
--allow-unauthenticated \
--port=8080 \
--memory=512Mi \
--cpu=1 \
--set-env-vars="DB_HOST=${DB_HOST},DB_PORT=${DB_PORT},DB_NAME=${DB_NAME},DB_USER=${DB_USER},DB_PASSWORD=${DB_PASSWORD},PROJECT_ID=${PROJECT_ID},FLASK_ENV=production" \
--project=${PROJECT_ID}
# Step 3: Get the service URL
echo ""
echo "Step 3: Getting service URL..."
SERVICE_URL=$(gcloud run services describe ${SERVICE_NAME} --platform=managed --region=${REGION} --format='value(status.url)')
echo ""
echo "============================================="
echo "✅ Cortex deployed successfully!"
echo "🌐 URL: $SERVICE_URL"
echo "📋 API: $SERVICE_URL/api/query"
echo "============================================="
echo ""
echo "Next steps:"
echo "1. Set up Cloud SQL PostgreSQL database and run schema.sql + seed.sql"
echo "2. Configure Google OAuth for Gmail/Calendar APIs"
echo "3. Submit your project at: https://vision.hack2skill.com/event/apac-genaiacademy"