-
Notifications
You must be signed in to change notification settings - Fork 1
/
devenv.sh
42 lines (34 loc) · 1.04 KB
/
devenv.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
#!/usr/bin/env bash
set -ex
[[ $UID -eq 0 ]] || { echo "Run as root"; exit 1; }
CONTAINER_NAME="flowty-dev"
docker build -t flowty-dev --file Dockerfile.dev .
if docker ps -a | grep "$CONTAINER_NAME" 2>&1 >/dev/null; then
CONTAINER_EXISTS=1
else
CONTAINER_EXISTS=0
fi
if docker ps | grep "$CONTAINER_NAME" 2>&1 >/dev/null; then
CONTAINER_IS_RUNNING=1
else
CONTAINER_IS_RUNNING=0
fi
if [[ $CONTAINER_EXISTS -eq 0 ]]; then
# --cap-add=SYS_PTRACE
# Supports the use of tools like GDB that use ptrace
# --security-opt seccomp=unconfined
# Disable secure computing mode, as when enabled, it disables the availability
# of syscalls used in gdb and the like
docker run -it \
--name $CONTAINER_NAME \
--runtime=nvidia \
--mount type=bind,source="$PWD",target="/app" \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
flowty-dev
else
if [[ $CONTAINER_IS_RUNNING -eq 0 ]]; then
docker start "$CONTAINER_NAME"
fi
docker attach "$CONTAINER_NAME"
fi