-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup-gcloud.sh
More file actions
executable file
·74 lines (60 loc) · 2.11 KB
/
setup-gcloud.sh
File metadata and controls
executable file
·74 lines (60 loc) · 2.11 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
#!/bin/bash
# Google Cloud Setup Script
# Run this to set up your Google Cloud environment
set -e
echo "🚀 Setting up Google Cloud for Strategy Optimizer deployment..."
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Check if gcloud is installed
if ! command -v gcloud &> /dev/null; then
echo -e "${RED}❌ gcloud CLI not found!${NC}"
echo "Install it from: https://cloud.google.com/sdk/docs/install"
echo ""
echo "For Linux/macOS:"
echo "curl https://sdk.cloud.google.com | bash"
echo "exec -l \$SHELL"
exit 1
fi
echo -e "${GREEN}✅ gcloud CLI found${NC}"
# Check if user is authenticated
if ! gcloud auth list --filter=status:ACTIVE --format="value(account)" | grep -q .; then
echo -e "${YELLOW}🔐 Authenticating with Google Cloud...${NC}"
gcloud auth login
fi
# Set or create project
echo -e "${YELLOW}📋 Setting up Google Cloud project...${NC}"
echo ""
echo "Enter your Google Cloud Project ID (or press Enter to create a new one):"
read -r PROJECT_ID
if [ -z "$PROJECT_ID" ]; then
PROJECT_ID="strategy-optimizer-$(date +%s)"
echo -e "${YELLOW}📝 Creating new project: $PROJECT_ID${NC}"
gcloud projects create $PROJECT_ID
fi
# Set the project
gcloud config set project $PROJECT_ID
echo -e "${GREEN}✅ Using project: $PROJECT_ID${NC}"
# Enable required APIs
echo -e "${YELLOW}⚙️ Enabling required APIs...${NC}"
gcloud services enable run.googleapis.com
gcloud services enable containerregistry.googleapis.com
gcloud services enable cloudbuild.googleapis.com
# Set default region
echo -e "${YELLOW}🌍 Setting default region to us-central1...${NC}"
gcloud config set run/region us-central1
echo ""
echo -e "${GREEN}🎉 Google Cloud setup complete!${NC}"
echo ""
echo -e "${YELLOW}📋 Your setup:${NC}"
echo "Project ID: $PROJECT_ID"
echo "Region: us-central1"
echo "APIs enabled: Cloud Run, Container Registry, Cloud Build"
echo ""
echo -e "${GREEN}✅ Ready for deployment!${NC}"
# Save project info
echo "PROJECT_ID=$PROJECT_ID" > .env.gcloud
echo "REGION=us-central1" >> .env.gcloud
echo "PROJECT setup saved to .env.gcloud"