-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathinit-environment.sh
More file actions
executable file
·148 lines (123 loc) · 3.2 KB
/
Copy pathinit-environment.sh
File metadata and controls
executable file
·148 lines (123 loc) · 3.2 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
#!/usr/bin/env bash
set -e
AXON_SERVER_VERSION="4.6.11"
MYSQL_VERSION="9.6.0"
POSTGRES_VERSION="18.3"
MONGODB_VERSION="8.2.5"
TIMEOUT=120
NETWORK_NAME="axon-springboot-websocket-net"
echo
echo "Starting environment"
echo "===================="
echo
echo "Creating network"
echo "----------------"
docker network create "$NETWORK_NAME" 2>/dev/null || true
echo
echo "Starting axon-server"
echo "--------------------"
docker rm -f axon-server 2>/dev/null || true
docker run -d \
--name axon-server \
-p 8024:8024 -p 8124:8124 \
--network="$NETWORK_NAME" \
"axoniq/axonserver:${AXON_SERVER_VERSION}"
echo
echo "Starting mysql"
echo "--------------"
docker rm -f mysql 2>/dev/null || true
docker run -d \
--name mysql \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=customerdb \
--health-cmd='mysqladmin ping -u root --password=secret' \
--health-interval=3s \
--health-timeout=3s \
--health-retries=5 \
--network="$NETWORK_NAME" \
"mysql:${MYSQL_VERSION}"
echo
echo "Starting postgres"
echo "-----------------"
docker rm -f postgres 2>/dev/null || true
docker run -d \
--name postgres \
-p 5432:5432 \
-e POSTGRES_DB=restaurantdb \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_USER=postgres \
--health-cmd='pg_isready -U postgres' \
--health-interval=3s \
--health-timeout=3s \
--health-retries=5 \
--network="$NETWORK_NAME" \
"postgres:${POSTGRES_VERSION}"
echo
echo "Starting mongodb"
echo "----------------"
docker rm -f mongodb 2>/dev/null || true
docker run -d \
--name mongodb \
-p 27017:27017 \
--health-cmd="echo 'db.stats().ok' | mongosh localhost:27017/foodorderingdb --quiet" \
--health-interval=3s \
--health-timeout=3s \
--health-retries=5 \
--network="$NETWORK_NAME" \
"mongo:${MONGODB_VERSION}"
echo
echo "Waiting for postgres to be ready"
echo "--------------------------------"
SECONDS=0
while [ "$(docker inspect --format='{{.State.Health.Status}}' postgres 2>/dev/null)" != "healthy" ]; do
if [ "$SECONDS" -ge "$TIMEOUT" ]; then
echo "TIMEOUT waiting for postgres to be ready"
exit 1
fi
sleep 2
done
echo "postgres is ready!"
echo
echo "Waiting for mongodb to be ready"
echo "-------------------------------"
SECONDS=0
while [ "$(docker inspect --format='{{.State.Health.Status}}' mongodb 2>/dev/null)" != "healthy" ]; do
if [ "$SECONDS" -ge "$TIMEOUT" ]; then
echo "TIMEOUT waiting for mongodb to be ready"
exit 1
fi
sleep 2
done
echo "mongodb is ready!"
echo
echo "Waiting for mysql to be ready"
echo "-----------------------------"
SECONDS=0
while [ "$(docker inspect --format='{{.State.Health.Status}}' mysql 2>/dev/null)" != "healthy" ]; do
if [ "$SECONDS" -ge "$TIMEOUT" ]; then
echo "TIMEOUT waiting for mysql to be ready"
exit 1
fi
sleep 2
done
echo "mysql is ready!"
echo
echo "Waiting for axon-server to be ready"
echo "-----------------------------------"
SECONDS=0
while true; do
if curl -sf "http://localhost:8024" > /dev/null 2>&1; then
echo "axon-server is ready!"
break
fi
if [ "$SECONDS" -ge "$TIMEOUT" ]; then
echo "TIMEOUT waiting for axon-server to be ready"
exit 1
fi
sleep 2
done
echo
echo "Environment Up and Running"
echo "=========================="
echo