-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_docker_testAll.sh
More file actions
70 lines (58 loc) · 2.19 KB
/
start_docker_testAll.sh
File metadata and controls
70 lines (58 loc) · 2.19 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
#!/bin/bash
# -----------------------------------------------------------------------------
# This script checks if Azurite and are running.
# Those containers are required to run unit tests for Azure and AWS.
# If they are already running, it does nothing.
# If either or both containers are not running, it starts them using docker-compose.
# -----------------------------------------------------------------------------
# Define the container names
Azurite="azurite"
Localstack="localstack"
# Define the docker-compose file
Azurite_File="docker/docker-compose-azurite.yml"
Localstack_File="docker/docker-compose-localstack.yml"
# Function to check if a container is running
is_container_running() {
container_name="$1" # Take container name as an argument
docker ps --filter "name=${container_name}" --format '{{.Names}}' | grep -w "${container_name}"
}
# Maximum wait time (in seconds)
TIMEOUT=60
SLEEP_INTERVAL=5 # Check interval in seconds
# Check if both containers are running
Azurite_Running=$(is_container_running "${Azurite}")
Localstack_Running=$(is_container_running "${Localstack}")
All_Running=false
if [[ -n "$Azurite_Running" && -n "$Localstack_Running" ]]; then
All_Running=true
echo "Both containers '$Azurite' and '$Localstack' are already running."
else
echo "Starting missing containers"
if [[ -z "$Azurite_Running" ]]; then
echo "Starting '$Azurite'..."
docker-compose -f $Azurite_File up -d
fi
if [[ -z "$Localstack_Running" ]]; then
echo "Starting '$Localstack'..."
docker-compose -f $Localstack_File up -d
fi
# Wait for all containers to be ready
echo "Waiting for all containers to be fully running..."
SECONDS=0
while [ $SECONDS -lt $TIMEOUT ]; do
ALL_READY=true
if ! is_container_running "$Azurite"; then
echo "Waiting for $Azurite to be ready..."
ALL_READY=false
fi
if ! is_container_running "$Localstack"; then
echo "Waiting for Localstack to be ready..."
ALL_READY=false
fi
if [ "$ALL_READY" = true ]; then
echo "All containers are now running!"
break
fi
sleep $SLEEP_INTERVAL
done
fi