-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-docker.sh
More file actions
executable file
·43 lines (36 loc) · 1.38 KB
/
start-docker.sh
File metadata and controls
executable file
·43 lines (36 loc) · 1.38 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
#!/bin/bash
# Start the docker containers defined in the docker-compose.yaml with a unique project name
# Get the repo (current directory) name
REPO_NAME=$(basename "$PWD")
# Remove any existing containers with hardcoded names to avoid conflicts
for cname in studio order-bff order-api inventory-api; do
if [ $(docker ps -a -q -f name="^/${cname}$") ]; then
echo "Removing existing container: $cname"
docker rm -f "$cname"
fi
done
docker compose -p "$REPO_NAME" -f specmatic-studio-demo/docker-compose.yaml pull
docker compose -p "$REPO_NAME" -f specmatic-studio-demo/docker-compose.yaml up -d
# Wait until required endpoints are accessible
MAX_ATTEMPTS=30
SLEEP_SECONDS=2
wait_for_url() {
local url="$1"
local attempt=1
echo "Waiting for $url to become accessible..."
while [ $attempt -le $MAX_ATTEMPTS ]; do
if curl --silent --fail "$url" > /dev/null; then
echo "$url is accessible."
return 0
fi
echo "Attempt $attempt/$MAX_ATTEMPTS: $url not accessible yet. Waiting $SLEEP_SECONDS seconds..."
sleep $SLEEP_SECONDS
attempt=$((attempt + 1))
done
echo "Error: $url was not accessible after $((MAX_ATTEMPTS * SLEEP_SECONDS)) seconds."
return 1
}
wait_for_url "http://localhost:8095/health" || exit 1
wait_for_url "http://localhost:8090/products" || exit 1
wait_for_url "http://localhost:8080/health" || exit 1
wait_for_url "http://localhost:9000/_specmatic/studio" || exit 1