-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdev-rebuild.sh
More file actions
executable file
·129 lines (113 loc) · 3.9 KB
/
dev-rebuild.sh
File metadata and controls
executable file
·129 lines (113 loc) · 3.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
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
#!/bin/bash
# GeoPulse Development Container Rebuild Script
# Usage: ./dev-rebuild.sh [backend|frontend|both] [--env=dev|e2e]
set -e
COMPONENT=${1:-both}
ENVIRONMENT="dev"
# Parse environment argument
for arg in "$@"; do
case $arg in
--env=*)
ENVIRONMENT="${arg#*=}"
shift
;;
esac
done
# Set environment-specific variables
if [[ "$ENVIRONMENT" == "e2e" ]]; then
COMPOSE_FILE="tests/docker-compose.e2e.yml"
BACKEND_CONTAINER="geopulse-backend-e2e"
FRONTEND_CONTAINER="geopulse-ui-e2e"
BACKEND_PORT="8081"
FRONTEND_PORT="5556"
echo "🧪 Using E2E testing environment"
else
COMPOSE_FILE="docker-compose.yml"
BACKEND_CONTAINER="geopulse-backend"
FRONTEND_CONTAINER="geopulse-ui"
BACKEND_PORT="8080"
FRONTEND_PORT="5555"
echo "🚀 Using development environment"
fi
rebuild_backend() {
echo "🔧 Rebuilding backend container ($BACKEND_CONTAINER)..."
if [[ "$ENVIRONMENT" == "e2e" ]]; then
# E2E uses build context, rebuild directly
echo "📦 Building backend for E2E..."
docker-compose -f $COMPOSE_FILE build geopulse-backend-e2e
else
# Dev uses pre-built images
echo "📦 Building backend image..."
make build-backend-local
fi
# Restart backend container
echo "🔄 Restarting backend container..."
docker-compose -f $COMPOSE_FILE stop $BACKEND_CONTAINER
docker-compose -f $COMPOSE_FILE rm -f $BACKEND_CONTAINER
docker-compose -f $COMPOSE_FILE up -d $BACKEND_CONTAINER
echo "✅ Backend rebuilt and restarted!"
}
rebuild_frontend() {
echo "🔧 Rebuilding frontend container ($FRONTEND_CONTAINER)..."
if [[ "$ENVIRONMENT" == "e2e" ]]; then
# E2E uses build context, rebuild directly
echo "📦 Building frontend for E2E..."
docker-compose -f $COMPOSE_FILE build geopulse-ui-e2e
else
# Dev uses pre-built images
echo "📦 Building frontend image..."
make build-frontend-local
fi
# Restart frontend container
echo "🔄 Restarting frontend container..."
docker-compose -f $COMPOSE_FILE stop $FRONTEND_CONTAINER
docker-compose -f $COMPOSE_FILE rm -f $FRONTEND_CONTAINER
docker-compose -f $COMPOSE_FILE up -d $FRONTEND_CONTAINER
echo "✅ Frontend rebuilt and restarted!"
}
case $COMPONENT in
"backend")
rebuild_backend
;;
"frontend")
rebuild_frontend
;;
"both")
rebuild_backend
rebuild_frontend
;;
*)
echo "❌ Usage: ./dev-rebuild.sh [backend|frontend|both] [--env=dev|e2e]"
echo ""
echo "Components:"
echo " backend - Rebuild only backend container"
echo " frontend - Rebuild only frontend container"
echo " both - Rebuild both containers (default)"
echo ""
echo "Environments:"
echo " --env=dev - Development environment (default)"
echo " Containers: geopulse-backend, geopulse-ui"
echo " Ports: :8080, :5555"
echo ""
echo " --env=e2e - E2E testing environment"
echo " Containers: geopulse-backend-e2e, geopulse-ui-e2e"
echo " Ports: :8081, :5556"
echo ""
echo "Examples:"
echo " ./dev-rebuild.sh backend # Rebuild dev backend"
echo " ./dev-rebuild.sh both --env=e2e # Rebuild E2E containers"
exit 1
;;
esac
echo ""
echo "🎉 Container rebuild complete!"
echo "📊 Backend: http://localhost:$BACKEND_PORT"
echo "🌐 Frontend: http://localhost:$FRONTEND_PORT"
echo ""
if [[ "$ENVIRONMENT" == "e2e" ]]; then
echo "💡 To run E2E tests:"
echo " cd tests && npm run test:e2e"
else
echo "💡 To run E2E tests against dev environment:"
echo " cd tests && BASE_URL=http://localhost:5555 API_BASE_URL=http://localhost:8080 npm run test:e2e"
fi