-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_microservices.sh
executable file
·59 lines (52 loc) · 2.11 KB
/
start_microservices.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
#!/bin/bash
# Array of directories containing docker-compose.yml files
directories=(
"./authorization-ms"
"./gatway-ms"
"./taskManagement-ms"
# 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 todo-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! 🎉"