-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-dev.sh
More file actions
executable file
·37 lines (31 loc) · 868 Bytes
/
stop-dev.sh
File metadata and controls
executable file
·37 lines (31 loc) · 868 Bytes
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
#!/usr/bin/env bash
set -euo pipefail
DELETE_CONTAINERS=false
SESSION_NAME="${TMUX_SESSION_NAME:-ando-dev}"
while getopts ":d" opt; do
case "$opt" in
d)
DELETE_CONTAINERS=true
;;
*)
echo "Usage: $0 [-d]"
echo " -d remove containers (docker compose down)"
exit 1
;;
esac
done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
COMPOSE_FILE="$SCRIPT_DIR/docker-compose.yml"
if [ "$DELETE_CONTAINERS" = true ]; then
docker compose -f "$COMPOSE_FILE" down --remove-orphans || true
else
docker compose -f "$COMPOSE_FILE" stop || true
fi
if command -v tmux >/dev/null 2>&1 && tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
tmux kill-session -t "$SESSION_NAME"
fi
if [ "$DELETE_CONTAINERS" = true ]; then
echo "Dev services stopped and containers removed."
else
echo "Dev services stopped."
fi