-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartMicroservices.sh
60 lines (53 loc) Β· 2.12 KB
/
startMicroservices.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
#!/bin/bash
# Array of directories containing docker-compose.yml files
directories=(
"./bookService"
"./gatewayService"
"./socialService"
"./userService"
# Add more directories as needed
)
echo "==========================="
echo "π Starting microservices π"
echo "Your computer is having a hard time running all the microservices at once. But don't worry, I've got you covered! π"
echo "I will create local-compose.yml files for you, each with its own database. π"
echo "We'll use Nginx as part of the PHP image for a more optimized setup. π"
echo "Do you want to create a new network? (This is useful if it's your first time running the microservices) π [Y/n]"
read -r network_reply
if [[ $network_reply =~ ^[Yy]$ ]]; then
echo "==========================="
echo "Creating a new network... β‘οΈ"
docker network create user-network
echo "New network 'mynetwork' created successfully! π"
fi
echo "Do you want to use local-compose.yml files? (These files provide better resource management) π [Y/n]"
read -r compose_reply
if [[ $compose_reply =~ ^[Yy]$ ]]; then
echo "==========================="
echo "Starting microservices with local-compose.yml... π"
for dir in "${directories[@]}"; do
echo "π Starting microservices in directory: $dir"
cd "$dir" || exit
pwd
docker-compose -f local-compose.yml up -d --build --remove-orphans
# docker-compose -f local-compose.yml logs -f &
echo "==========================="
echo "π Docker-compose exited with status $?"
cd ..
done
else
echo "==========================="
echo "Starting microservices with docker-compose.yml... π"
for dir in "${directories[@]}"; do
echo "π Starting microservices in directory: $dir"
cd "$dir" || exit
pwd
docker-compose up -d --build --remove-orphans
# docker-compose logs -f &
echo "==========================="
echo "π Docker-compose exited with status $?"
cd ..
done
fi
echo "==========================="
echo "Microservices deployment completed! π"