generated from GDGVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
vitty.sh
executable file
·71 lines (64 loc) · 2.01 KB
/
vitty.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
#!/bin/sh
# Vitty
# Handy set of commands to run to get a new server up and running
if [ "$1" = "local" ]; then
shift # Discard the first argument
environment="local"
file="docker-compose-local.yaml"
else
environment="production"
file="docker-compose-prod.yaml"
fi
command=$1
if [ -z "$command" ]; then
echo
echo "██╗ ██╗██╗████████╗████████╗██╗ ██╗"
echo "██║ ██║██║╚══██╔══╝╚══██╔══╝╚██╗ ██╔╝"
echo "██║ ██║██║ ██║ ██║ ╚████╔╝ "
echo "╚██╗ ██╔╝██║ ██║ ██║ ╚██╔╝ "
echo " ╚████╔╝ ██║ ██║ ██║ ██║ "
echo " ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ "
echo
echo "Environment: $environment"
echo
echo "Usage: vitty [command]"
echo
echo "Available commands:"
echo " up: Start the server"
echo " down: Stop the server"
echo " restart: Restart the server"
echo " cli: Run a command inside the container"
echo " logs: Show the logs of the container"
exit 1
fi
# Start server command
if [ "$command" = "up" ]; then
echo "Starting server"
docker compose -f "$file" up -d --build
exit 1
fi
# Stop server command
if [ "$command" = "down" ]; then
echo "Stopping server"
docker compose -f "$file" down
exit 1
fi
# Restart server command
if [ "$command" = "restart" ]; then
echo "Restarting server"
docker compose -f "$file" down
docker compose -f "$file" up -d --build
exit 1
fi
# Show logs command
if [ "$command" = "logs" ]; then
echo "Showing logs"
docker compose -f "$file" logs -f
exit 1
fi
# Management commands
if [ "$command" = "cli" ]; then
shift # Discard the first argument
docker compose -f "$file" run --rm vitty-api ./bin/vitty "$@"
exit 1
fi