forked from tembolo1284/HighPerformanceTradingGateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-run.sh
executable file
·66 lines (59 loc) · 1.52 KB
/
docker-run.sh
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
#!/bin/bash
# Function to stop and remove existing containers
cleanup() {
echo "Cleaning up existing containers..."
docker-compose down
docker network rm cpp-net 2>/dev/null || true
docker system prune -f
}
# Function to ensure network exists
ensure_network() {
if ! docker network inspect cpp-net >/dev/null 2>&1; then
echo "Creating cpp-net network..."
docker network create cpp-net
fi
}
# Function to build the Docker image
build_image() {
echo "Building Docker image..."
ensure_network
docker-compose build
}
# Function to run the server
run_server() {
echo "Starting server..."
ensure_network
docker-compose up server
}
# Function to run the client
run_client() {
echo "Starting client..."
ensure_network
# Default argument to send a single FIX order if no additional arguments are provided
docker-compose run --rm client -o "35=D|49=SENDER|56=TARGET|11=ORDER123|55=AAPL|54=1|44=150.50|38=100|40=2|" "$@"
}
# Main script
case "$1" in
"build")
build_image
;;
"server")
cleanup
run_server
;;
"client")
shift
run_client "$@"
;;
"clean")
cleanup
;;
*)
echo "Usage: $0 {build|server|client|clean} [client args]"
echo " build - Build the Docker image"
echo " server - Run the server"
echo " client - Run the client with optional arguments"
echo " clean - Clean up containers and networks"
exit 1
;;
esac