forked from praetorian-inc/google-redirector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·67 lines (55 loc) · 2.02 KB
/
deploy.sh
File metadata and controls
executable file
·67 lines (55 loc) · 2.02 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
set -e
# Check for redirector name argument
if [ -z "$1" ]; then
echo "❌ Error: Redirector name is required"
echo "Usage: ./deploy.sh <redirector-name>"
echo "Example: ./deploy.sh acmecorp"
exit 1
fi
REDIRECTOR_NAME="$1"
echo "🚀 Deploying Google Redirector '$REDIRECTOR_NAME' to Google Cloud Run"
if [ -z "$BACKEND_URL" ]; then
echo "❌ Error: BACKEND_URL environment variable is not set"
echo "Example: export BACKEND_URL=https://your-backend.com"
exit 1
fi
PROJECT_ID=$(gcloud config get-value project)
if [ -z "$PROJECT_ID" ]; then
echo "❌ Error: No GCP project configured. Run 'gcloud config set project YOUR-PROJECT-ID' first"
exit 1
fi
echo "📋 Using GCP project: $PROJECT_ID"
SERVICE_NAME="redirector-$REDIRECTOR_NAME"
REGION=${GOOGLE_CLOUD_REGION:-"us-central1"}
REPO_NAME="google-redirector"
IMAGE_NAME="$REGION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/$SERVICE_NAME"
echo "🏗️ Setting up Artifact Registry repository..."
gcloud artifacts repositories create $REPO_NAME \
--repository-format=docker \
--location=$REGION \
--description="Google Cloud Redirector images" \
--quiet 2>/dev/null || echo "Repository already exists, continuing..."
echo "📦 Building Docker image..."
docker build -t $IMAGE_NAME .
echo "🔐 Configuring Docker for Artifact Registry..."
gcloud auth configure-docker $REGION-docker.pkg.dev
echo "📤 Pushing image to Artifact Registry..."
docker push $IMAGE_NAME
echo "☁️ Deploying to Cloud Run..."
gcloud run deploy $SERVICE_NAME \
--image $IMAGE_NAME \
--platform managed \
--region $REGION \
--allow-unauthenticated \
--set-env-vars "BACKEND_URL=$BACKEND_URL" \
--set-env-vars "VERIFICATION_HEADER=$VERIFICATION_HEADER" \
--memory 512Mi \
--cpu 1 \
--concurrency 100 \
--timeout 300 \
--max-instances 10 \
--min-instances 1
echo "✅ Deployment complete!"
echo "🌐 Service URL:"
gcloud run services describe $SERVICE_NAME --platform managed --region $REGION --format 'value(status.url)'