-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrun.sh
executable file
·77 lines (68 loc) · 1.88 KB
/
run.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
75
76
77
#!/bin/bash
COMPOSE_FILE="docker-compose.yaml"
function show_help() {
echo "Usage: $0 [OPTION]"
echo "Manage the Docker Compose services for brain-rot-tok."
echo
echo "Options:"
echo " --help Show this help message and exit."
echo " --stop Stop the running containers."
echo " --remove-container Stop and remove all containers."
echo " --remove-all Stop and remove all containers, then remove images."
echo " --logs View logs of running services."
echo " (no option) Start the services (builds if necessary)."
}
function start_services() {
echo "Starting services..."
docker compose -f $COMPOSE_FILE up -d --build
sleep 5
open_browser
}
function stop_services() {
echo "Stopping services..."
docker compose -f $COMPOSE_FILE stop
}
function remove_containers() {
echo "Removing containers..."
docker compose -f $COMPOSE_FILE down
}
function remove_all() {
echo "Removing all containers and images..."
docker compose -f $COMPOSE_FILE down --rmi all
}
function view_logs() {
echo "Displaying logs..."
docker compose -f $COMPOSE_FILE logs -f
}
function open_browser() {
echo "Opening application in browser..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
xdg-open "http://localhost:5173/"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
start "http://localhost:5173/"
elif [[ "$OSTYPE" == "darwin"* ]]; then
open "http://localhost:5173/"
else
echo "Unsupported OS for opening the browser."
fi
}
case "$1" in
--help)
show_help
;;
--stop)
stop_services
;;
--remove-container)
remove_containers
;;
--remove-all)
remove_all
;;
--logs)
view_logs
;;
*)
start_services
;;
esac