This repository was archived by the owner on Jul 11, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathdeploy-cloudflare.sh
More file actions
executable file
·103 lines (88 loc) · 2.45 KB
/
Copy pathdeploy-cloudflare.sh
File metadata and controls
executable file
·103 lines (88 loc) · 2.45 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Cloudflare Deployment Script for Gamify
# This script deploys both frontend and backend to Cloudflare
set -e
echo "🚀 Gamify Cloudflare Deployment"
echo "================================="
echo ""
# Check if Wrangler is installed
if ! command -v wrangler &> /dev/null; then
echo "❌ Wrangler CLI is not installed."
echo " Install with: npm install -g wrangler"
exit 1
fi
# Function to deploy backend (Workers)
deploy_backend() {
echo "📦 Deploying Backend (Cloudflare Workers)..."
echo " Note: This will deploy the Express API to Workers"
echo " Configuration: wrangler.jsonc"
echo ""
cd /home/dead/repos/Gamify
npx wrangler deploy --env production
if [ $? -eq 0 ]; then
echo "✅ Backend deployed successfully!"
else
echo "❌ Backend deployment failed!"
return 1
fi
}
# Function to deploy frontend (Pages)
deploy_frontend() {
echo ""
echo "🌐 Deploying Frontend (Cloudflare Pages)..."
echo " Configuration: wrangler.toml"
echo ""
cd /home/dead/repos/Gamify/client
npm run build
if [ $? -eq 0 ]; then
cd /home/dead/repos/Gamify
npx wrangler pages deploy ./client/dist
echo "✅ Frontend deployed successfully!"
else
echo "❌ Frontend build failed!"
return 1
fi
}
# Function for local testing
test_local() {
echo ""
echo "🧪 Running local tests..."
echo ""
cd /home/dead/repos/Gamify/client
npm run build
cd /home/dead/repos/Gamify/server
echo " Backend: http://localhost:8787"
echo " Frontend: http://localhost:8788"
npx wrangler dev --local --port 8787 server/worker.js &
echo "✅ Local test server running!"
}
# Parse arguments
case "$1" in
backend)
deploy_backend
;;
frontend)
deploy_frontend
;;
all)
deploy_backend
deploy_frontend
;;
test)
test_local
;;
*)
echo "Usage: $0 {backend|frontend|all|test}"
echo ""
echo "Options:"
echo " backend Deploy backend to Cloudflare Workers"
echo " frontend Deploy frontend to Cloudflare Pages"
echo " all Deploy both backend and frontend"
echo " test Run local test server"
exit 1
;;
esac
echo ""
echo "================================="
echo "🎉 Deployment Complete!"
echo "================================="