-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-deployment-ready.sh
More file actions
executable file
·213 lines (177 loc) · 4.93 KB
/
Copy pathcheck-deployment-ready.sh
File metadata and controls
executable file
·213 lines (177 loc) · 4.93 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#!/bin/bash
# 🌱 Botanic Defenders - Local Build & Test Script
# This script helps test if your project will build correctly on Vercel/Render
set -e
echo "🌱 Botanic Defenders - Local Build Test"
echo "=========================================="
echo ""
# Colors for output
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Function to print status
print_status() {
echo -e "${GREEN}✓${NC} $1"
}
print_error() {
echo -e "${RED}✗${NC} $1"
}
print_warning() {
echo -e "${YELLOW}⚠${NC} $1"
}
# Test Backend Build
echo ""
echo "📦 Testing Backend Build..."
echo "---"
cd backend
# Check if requirements.txt exists
if [ ! -f "requirements.txt" ]; then
print_error "requirements.txt not found!"
exit 1
fi
print_status "requirements.txt found"
# Check Python version
python_version=$(python3 --version 2>&1 | awk '{print $2}')
print_status "Python version: $python_version"
# Try to verify imports without installing (simulates Vercel build)
echo ""
echo "Checking critical imports..."
# Create a simple Python script to check imports
cat > /tmp/check_imports.py << 'EOF'
try:
import fastapi
print("✓ fastapi")
except ImportError:
print("✗ fastapi (not installed, but will be in deployment)")
try:
import transformers
print("✓ transformers")
except ImportError:
print("✗ transformers (not installed, but will be in deployment)")
try:
import torch
print("✓ torch")
except ImportError:
print("✗ torch (not installed, but will be in deployment)")
try:
import google.generativeai
print("✓ google.generativeai")
except ImportError:
print("✗ google.generativeai (not installed, but will be in deployment)")
EOF
python3 /tmp/check_imports.py
rm /tmp/check_imports.py
print_status "Backend dependency check complete"
# Check vercel.json
echo ""
if [ -f "vercel.json" ]; then
print_status "vercel.json found ✓"
# Check if it has api/index.py (not main.py)
if grep -q "api/index.py" vercel.json; then
print_status "vercel.json configured for api/index.py ✓"
else
print_error "vercel.json not configured for api/index.py"
exit 1
fi
else
print_error "vercel.json not found!"
exit 1
fi
# Check api/index.py exists
if [ ! -f "api/index.py" ]; then
print_error "api/index.py not found!"
exit 1
fi
print_status "api/index.py found ✓"
cd ..
# Test Frontend Build
echo ""
echo "📦 Testing Frontend Build..."
echo "---"
cd frontend
# Check if package.json exists
if [ ! -f "package.json" ]; then
print_error "package.json not found!"
exit 1
fi
print_status "package.json found"
# Check Node version
node_version=$(node --version 2>/dev/null || echo "not found")
npm_version=$(npm --version 2>/dev/null || echo "not found")
print_status "Node version: $node_version"
print_status "NPM version: $npm_version"
# Check vercel.json
echo ""
if [ -f "vercel.json" ]; then
print_status "vercel.json found ✓"
# Check framework
if grep -q "nextjs" vercel.json; then
print_status "vercel.json configured for Next.js ✓"
else
print_error "vercel.json not configured for Next.js"
exit 1
fi
else
print_error "vercel.json not found!"
exit 1
fi
# Check critical files
echo ""
echo "Checking critical Next.js files..."
if [ -f "next.config.mjs" ]; then
print_status "next.config.mjs found"
else
print_warning "next.config.mjs not found (may be needed)"
fi
if [ -f "tsconfig.json" ]; then
print_status "tsconfig.json found"
else
print_error "tsconfig.json not found!"
exit 1
fi
if [ -d "app" ]; then
print_status "app directory found (Next.js App Router)"
else
print_error "app directory not found!"
exit 1
fi
if [ -f "app/api/plant-health/predict/route.ts" ]; then
print_status "API route /api/plant-health/predict found"
else
print_error "API route /api/plant-health/predict not found!"
exit 1
fi
# Check .env.local for backend URL
echo ""
if [ -f ".env.local" ]; then
if grep -q "BACKEND_URL" .env.local; then
backend_url=$(grep "BACKEND_URL" .env.local)
print_status ".env.local configured: $backend_url"
else
print_warning ".env.local exists but BACKEND_URL not set"
fi
else
print_warning ".env.local not found (using defaults)"
fi
cd ..
# Final summary
echo ""
echo "=========================================="
echo "✓ Pre-deployment checks complete!"
echo ""
echo "📋 Summary:"
echo " ✓ Backend structure ready for Vercel"
echo " ✓ Frontend structure ready for Vercel"
echo " ✓ API routes configured"
echo " ✓ Environment files in place"
echo ""
echo "🚀 Next steps:"
echo " 1. Push code to GitHub"
echo " 2. Deploy backend to Vercel/Render"
echo " 3. Deploy frontend to Vercel/Render"
echo " 4. Set environment variables in deployment dashboard"
echo " 5. Test deployed application"
echo ""
echo "📖 For detailed instructions, see: DEPLOYMENT_COMPLETE_GUIDE.md"
echo ""