-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·68 lines (57 loc) · 1.95 KB
/
deploy.sh
File metadata and controls
executable file
·68 lines (57 loc) · 1.95 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
#!/bin/bash
# Cloud Run Deployment Script for FastTTS API
# Usage: ./deploy.sh [PROJECT_ID] [REGION] [SERVICE_NAME]
set -e
# Configuration
PROJECT_ID="${1:-your-gcp-project-id}"
REGION="${2:-us-central1}"
SERVICE_NAME="${3:-fasttts-api}"
IMAGE_NAME="gcr.io/${PROJECT_ID}/${SERVICE_NAME}"
echo "🚀 Deploying FastTTS API to Google Cloud Run"
echo "================================================"
echo "Project ID: ${PROJECT_ID}"
echo "Region: ${REGION}"
echo "Service Name: ${SERVICE_NAME}"
echo "================================================"
# Check if gcloud is installed
if ! command -v gcloud &> /dev/null; then
echo "❌ Error: gcloud CLI is not installed"
echo "Please install it from: https://cloud.google.com/sdk/docs/install"
exit 1
fi
# Set the project
echo "📦 Setting GCP project..."
gcloud config set project ${PROJECT_ID}
# Enable required APIs
echo "🔧 Enabling required APIs..."
gcloud services enable cloudbuild.googleapis.com
gcloud services enable run.googleapis.com
gcloud services enable containerregistry.googleapis.com
# Build the container image
echo "🏗️ Building container image..."
gcloud builds submit --tag ${IMAGE_NAME}
# Deploy to Cloud Run
echo "🚢 Deploying to Cloud Run..."
gcloud run deploy ${SERVICE_NAME} \
--image ${IMAGE_NAME} \
--platform managed \
--region ${REGION} \
--allow-unauthenticated \
--memory 2Gi \
--cpu 2 \
--timeout 300 \
--concurrency 80 \
--max-instances 10 \
--port 8080
# Get the service URL
SERVICE_URL=$(gcloud run services describe ${SERVICE_NAME} --platform managed --region ${REGION} --format 'value(status.url)')
echo "================================================"
echo "✅ Deployment completed successfully!"
echo "🌐 Service URL: ${SERVICE_URL}"
echo "================================================"
echo ""
echo "Test your deployment:"
echo "curl '${SERVICE_URL}/tts?text=Hello%20World'"
echo ""
echo "Open in browser:"
echo "${SERVICE_URL}"