-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstart.sh
53 lines (48 loc) · 1.3 KB
/
start.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
#!/bin/bash
# Function to show usage
show_usage() {
echo "Usage: $0 [-i]"
echo " -i Run the application in interactive mode"
exit 1
}
# Parse command-line options
INTERACTIVE_MODE=false
while getopts "i" opt; do
case ${opt} in
i )
INTERACTIVE_MODE=true
;;
* )
show_usage
;;
esac
done
# Stop and remove any existing containers
echo "Stopping and removing existing containers..."
docker compose down
# Build the Docker images
echo "Building Docker images..."
docker compose build | tee build.log
echo "Docker images built."
# Start up the application stack
if [ "$INTERACTIVE_MODE" = true ]; then
echo "Starting up the application stack in interactive mode..."
docker compose up db -d
echo "Waiting for MySQL to start..."
until docker exec lazygrocer-db-1 mysqladmin ping --silent; do
sleep 1
done
echo "MySQL started."
docker compose run --rm -it app
else
echo "Starting up the application stack in detached mode..."
docker compose up -d
echo "Application stack started."
echo "Waiting for MySQL to start..."
until docker exec lazygrocer-db-1 mysqladmin ping --silent; do
sleep 1
done
echo "MySQL started."
echo "Following logs..."
docker compose logs -f
fi