-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-to-gcp.sh
More file actions
executable file
·70 lines (61 loc) · 2.41 KB
/
deploy-to-gcp.sh
File metadata and controls
executable file
·70 lines (61 loc) · 2.41 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
#!/bin/bash
# === CONFIGURABLE ===
PROJECT_ID=$(gcloud config get-value project)
ZONE="asia-south1-c"
VM_NAME="odoofinallarge-vm"
MACHINE_TYPE="e2-standard-2"
LOCAL_DIR="$(pwd)"
REMOTE_DIR="/home/$(whoami)/odoofinal"
DISK_SIZE="30GB"
echo "🚀 Creating VM instance with HTTP/2 support..."
# gcloud compute instances create "$VM_NAME" \
# --project="$PROJECT_ID" \
# --zone="$ZONE" \
# --machine-type="$MACHINE_TYPE" \
# --image-family=debian-11 \
# --image-project=debian-cloud \
# --boot-disk-size="$DISK_SIZE" \
# --tags=http-server,https-server \
# --quiet
# echo "🔐 Opening HTTP/HTTPS/HTTP2 firewall..."
# gcloud compute firewall-rules create allow-http-https-http2 \
# --allow tcp:80,tcp:443,tcp:3000-3200,tcp:9200,tcp:9300,tcp:9090 \
# --target-tags=http-server,https-server \
# --description="Allow HTTP, HTTPS, HTTP/2 and other ports for demo stack" \
# --quiet || true
# echo "🪝 Installing Docker & Docker Compose..."
# gcloud compute ssh "$VM_NAME" --zone="$ZONE" --command '
# sudo apt update &&
# sudo apt install -y docker.io docker-compose-v2 &&
# sudo usermod -aG docker $USER &&
# sudo systemctl enable docker &&
# sudo systemctl start docker
# '
echo "📦 Uploading local project to VM..."
gcloud compute scp --recurse "$LOCAL_DIR" "$VM_NAME:$REMOTE_DIR" --zone="$ZONE"
echo "� Setting up environment and building containers..."
gcloud compute ssh "$VM_NAME" --zone="$ZONE" --command "
cd $REMOTE_DIR && pnpm install && npx prisma generate &&
sudo docker compose down || true &&
sudo docker compose -f docker-compose.prod.yml up --build -d
"
echo "🌐 Fetching public IP..."
VM_IP=$(gcloud compute instances describe "$VM_NAME" --zone="$ZONE" --format='get(networkInterfaces[0].accessConfigs[0].natIP)')
echo "⏳ Waiting for services to be ready..."
sleep 30
echo "✅ Deployment complete!"
echo ""
echo "🔗 Your application URLs:"
echo " HTTP/2 Application: http://${VM_IP}:3000"
echo " Grafana Dashboard: http://${VM_IP}:3001"
echo " Prometheus: http://${VM_IP}:9090"
echo " Elasticsearch: http://${VM_IP}:9200"
echo ""
echo "📊 To check HTTP/2 support:"
echo " curl -I --http2 http://${VM_IP}:3000"
echo ""
echo "🔧 To connect to VM:"
echo " gcloud compute ssh $VM_NAME --zone=$ZONE"
echo ""
echo "📋 To view logs:"
echo " gcloud compute ssh $VM_NAME --zone=$ZONE --command 'cd $REMOTE_DIR && sudo docker compose -f docker-compose.prod.yml logs -f odoofinal'"