-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop-dev.sh
More file actions
executable file
·59 lines (51 loc) · 1.59 KB
/
Copy pathstop-dev.sh
File metadata and controls
executable file
·59 lines (51 loc) · 1.59 KB
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
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Dong Lab, Yale School of Medicine <https://donglab.org>
#
# SPDX-License-Identifier: CC0-1.0
# Stop the dev container so it can be resumed quickly with ./enter-dev.sh.
#
# Default (like `docker compose stop`): only stops the container, preserving its filesystem
#
# --down also remove the container (like `docker compose down`); the next
# start rebuilds it from the image and re-runs create-time setup
# -v|--volumes imply --down and also delete the dependency volumes, forcing a
# full reinstall of Python/Node deps on next start
#
set -e
cd "$(dirname "$0")"
CONTAINER="$(basename "$PWD")"
remove=0
volumes=0
for arg in "$@"; do
case "$arg" in
--down) remove=1 ;;
-v | --volumes)
remove=1
volumes=1
;;
*)
echo "[stop-dev] unknown option: $arg" >&2
exit 2
;;
esac
done
if [ "$remove" = 1 ]; then
if docker rm -f "$CONTAINER" >/dev/null 2>&1; then
echo "[stop-dev] removed container $CONTAINER"
else
echo "[stop-dev] no container named $CONTAINER"
fi
else
if docker stop "$CONTAINER" >/dev/null 2>&1; then
echo "[stop-dev] stopped container $CONTAINER (resume with ./enter-dev.sh)"
else
echo "[stop-dev] no running container named $CONTAINER"
fi
fi
if [ "$volumes" = 1 ]; then
if docker volume rm "${CONTAINER}-venv" "${CONTAINER}-node-modules" >/dev/null 2>&1; then
echo "[stop-dev] removed dependency volumes"
else
echo "[stop-dev] no dependency volumes to remove"
fi
fi