-
Notifications
You must be signed in to change notification settings - Fork 1
/
launch.sh
executable file
·88 lines (74 loc) · 1.52 KB
/
launch.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
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash
IMAGE_NAME="vision"
CONT_NAME=vision
DOCKER_CMD="docker run \
--network host \
--gpus all \
--shm-size=64gb \
-p ${JUPYTER_PORT}:8888 \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v /etc/shadow:/etc/shadow:ro \
-v $(pwd):/workspace \
-e HOME=/workspace \
-w /workspace"
usage() {
echo "Please read README."
}
build() {
set -x
DOCKER_FILE="docker/Dockerfile"
echo -e "Building ${DOCKER_FILE}..."
docker build \
-t ${IMAGE_NAME}:0.0.1 \
-t ${IMAGE_NAME}:latest \
-f ${DOCKER_FILE} .
}
dev() {
local DEV_IMG=${IMAGE_NAME}
while [[ $# -gt 0 ]]; do
case $1 in
-i|--image)
DEV_IMG="$2"
shift
shift
;;
-d|--deamon)
DOCKER_CMD="${DOCKER_CMD} -d"
shift
;;
*)
echo "Unknown option $1"
exit 1
;;
esac
done
$DOCKER_CMD \
--name ${CONT_NAME} \
-u $(id -u):$(id -u) \
-e PYTHONPATH=$DEV_PYTHONPATH \
-it --rm \
${DEV_IMG} \
bash
}
attach() {
DOCKER_CMD="docker exec"
CONTAINER_ID=$(docker ps | grep ${CONT_NAME} | cut -d' ' -f1)
${DOCKER_CMD} -it ${CONTAINER_ID} /bin/bash
exit
}
case $1 in
build)
"$@"
;;
dev)
"$@"
exit 0
;;
attach)
$@
;;
*)
usage
;;
esac