-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
69 lines (57 loc) · 1.9 KB
/
entrypoint.sh
File metadata and controls
69 lines (57 loc) · 1.9 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
#!/bin/bash
set -e
echo "🚀 [entrypoint.sh] Starting Pipeline Environment..."
# 1. Start Backend (Uvicorn) in Background
# We must use proper python path and ensure it listens on 0.0.0.0
echo "🚀 Starting Backend (Uvicorn)..."
# Using 'server:app' because your file is server.py
# '&' sends it to background
nohup uvicorn server:app --host 0.0.0.0 --port 8000 > backend_logs.txt 2>&1 &
BACKEND_PID=$!
# 2. Wait for Backend (TensorFlow needs time!)
echo "⏳ Waiting 15s for Backend to initialize..."
sleep 15
# 3. Start React App (Vite) in Background
# We MUST use --host to expose it to the container network,
# and --port 3000 to match the test expectations.
echo "🔄 Starting Vite Server on 0.0.0.0:3000..."
cd Client
# 'nohup' prevents the process from being tied to the shell, ensuring it runs
nohup npm run dev -- --host --port 3000 > ../frontend_logs.txt 2>&1 &
FRONTEND_PID=$!
cd ..
# 2. Wait for Port 3000 to be Ready
echo "⏳ Waiting for frontend to launch on localhost:3000..."
START_TIME=$(date +%s)
TIMEOUT=120 # 2 minutes timeout
while ! nc -z localhost 3000; do
CURRENT_TIME=$(date +%s)
ELAPSED=$((CURRENT_TIME - START_TIME))
if [ $ELAPSED -ge $TIMEOUT ]; then
echo "❌ Timeout waiting for Frontend!"
cat frontend_logs.txt
kill $FRONTEND_PID
exit 1
fi
sleep 2
done
echo "✅ Frontend is UP! (PID: $FRONTEND_PID)"
# 3. Run Selenium Tests
echo "🧪 Running Selenium E2E Tests..."
export BASE_URL="http://localhost:3000"
# Running pytests
# Write to /tmp first to avoid permission crashes on mounted volumes
echo "Running pytest..."
python -m pytest tests/test_app.py -v --junitxml=/tmp/test-results.xml
TEST_EXIT_CODE=$?
# 4. Cleanup & Exit
echo "🛑 Stopping Services..."
kill $FRONTEND_PID
kill $BACKEND_PID
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "🎉 Tests Passed!"
exit 0
else
echo "❌ Tests Failed! (Exit Code: $TEST_EXIT_CODE)"
exit $TEST_EXIT_CODE
fi