-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-app
More file actions
executable file
·105 lines (94 loc) · 3.86 KB
/
run-app
File metadata and controls
executable file
·105 lines (94 loc) · 3.86 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
#!/usr/bin/env bash
workspace="$(cd "$(dirname "$0")" && pwd)/docker"
MOBILE_ENABLED=false
for arg in "$@"; do
if [ "$arg" == "--mobile" ] || [ "$arg" == "-m" ]; then
MOBILE_ENABLED=true
break
fi
done
# -----------------------------------------------------------------------------
# Validates that Docker is installed and running
# -----------------------------------------------------------------------------
function validate_docker() {
if ! command -v docker &> /dev/null; then
echo "Error: Docker is not installed or not in PATH"
exit 1
fi
if ! docker info &> /dev/null; then
echo "Error: Docker daemon is not running"
exit 1
fi
}
# -----------------------------------------------------------------------------
# Create external docker network for all components
# -----------------------------------------------------------------------------
function create_network() {
local network_name="$1"
if [ -z "$(docker network ls -qf name=^"$network_name"$)" ]; then
echo "Creating $network_name..."
docker network create "$network_name"
else
echo "$network_name already exists, skipping creation."
fi
}
# -----------------------------------------------------------------------------
# Run Vault
# -----------------------------------------------------------------------------
function init_vault() {
docker exec -t vault-e2e sh "/tmp/init_vault.sh"
}
# -----------------------------------------------------------------------------
# Run Integrations
# -----------------------------------------------------------------------------
function run_integrations() {
docker compose -f "$workspace/docker-compose-integrations.yaml" --profile local up -d --force-recreate
if [ $? -ne 0 ]; then
echo "Error: Failed to start integrations. Stopping integrations..."
docker compose -f "$workspace/docker-compose-integrations.yaml" logs -t --tail=400 || true
docker compose -f "$workspace/docker-compose-integrations.yaml" down -v --timeout 10 || true
exit 1
fi
}
# -----------------------------------------------------------------------------
# Run Selenium Grid
# -----------------------------------------------------------------------------
function run_selenium_grid() {
docker compose -f "$workspace/docker-compose-selenium-grid.yaml" --profile local up -d --force-recreate
if [ $? -ne 0 ]; then
echo "Error: Failed to start Selenium Grid. Stopping selenium grid..."
docker compose -f "$workspace/docker-compose-selenium-grid.yaml" logs -t --tail=400 || true
docker compose -f "$workspace/docker-compose-selenium-grid.yaml" down -v --timeout 10 || true
exit 1
fi
}
# -----------------------------------------------------------------------------
# Run App
# -----------------------------------------------------------------------------
function run_app() {
docker compose -f "$workspace/docker-compose-mega-test-app.yaml" --profile local up -d --build --force-recreate
if [ $? -ne 0 ]; then
echo "Error: Failed to start mega-test-app. Stopping app..."
docker compose -f "$workspace/docker-compose-mega-test-app.yaml" logs -t || true
docker compose -f "$workspace/docker-compose-mega-test-app.yaml" down -v --timeout 10 || true
exit 1
fi
}
# -----------------------------------------------------------------------------
# Main entry point
# -----------------------------------------------------------------------------
function main() {
validate_docker
create_network e2e_network
run_integrations
init_vault
run_selenium_grid
run_app
if [ "$MOBILE_ENABLED" = true ]; then
echo "🚀 Mobile flag detected. Starting Android setup..."
sh ./run-android-device
else
echo "⏭️ Skipping mobile setup (use --mobile or -m to enable)."
fi
}
main