-
Notifications
You must be signed in to change notification settings - Fork 14
/
manage_app.sh
74 lines (70 loc) · 2.27 KB
/
manage_app.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Define the docker-compose file location
COMPOSE_FILE="docker-compose.yml"
# Display help message
function show_help() {
echo "Usage: $0 [option]"
echo "Options:"
echo " build Build the backend and frontend Docker images"
echo " start Start all services (backend, frontend, firebase)"
echo " stop Stop all services"
echo " restart Restart all services"
echo " logs Show logs for all services"
echo " logs-backend Show logs for the backend service"
echo " logs-frontend Show logs for the frontend service"
echo " logs-firebase Show logs for the firebase service"
echo " clean Stop and remove all containers, networks, and volumes"
echo " help Display this help message"
}
# Check if docker-compose file exists
if [ ! -f "$COMPOSE_FILE" ]; then
echo "Error: $COMPOSE_FILE not found!"
exit 1
fi
# Handle script arguments
case "$1" in
build)
echo "Building Docker images for backend and frontend..."
docker-compose -f $COMPOSE_FILE build
;;
start)
echo "Starting all services..."
docker-compose -f $COMPOSE_FILE up -d
;;
stop)
echo "Stopping all services..."
docker-compose -f $COMPOSE_FILE down
;;
restart)
echo "Restarting all services..."
docker-compose -f $COMPOSE_FILE down
docker-compose -f $COMPOSE_FILE up -d
;;
logs)
echo "Displaying logs for all services..."
docker-compose -f $COMPOSE_FILE logs -f
;;
logs-backend)
echo "Displaying logs for the backend service..."
docker-compose -f $COMPOSE_FILE logs -f backend
;;
logs-frontend)
echo "Displaying logs for the frontend service..."
docker-compose -f $COMPOSE_FILE logs -f frontend
;;
logs-firebase)
echo "Displaying logs for the firebase service..."
docker-compose -f $COMPOSE_FILE logs -f firebase
;;
clean)
echo "Cleaning up: stopping and removing all containers, networks, and volumes..."
docker-compose -f $COMPOSE_FILE down -v --remove-orphans
;;
help)
show_help
;;
*)
echo "Invalid option!"
show_help
;;
esac