forked from kgyrtkirk/hive-dev-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.bash
executable file
·89 lines (75 loc) · 2.4 KB
/
run.bash
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
#!/bin/bash
set -e
if [ "$1" == "-d" ];then
RUN_OPTS+=" -d"
shift
else
RUN_OPTS+=" -it"
fi
if [ "$1" != "" ];then
RUN_OPTS+=" --name $1 --hostname $1"
shift
fi
RUN_OPTS+=" -v hive-dev-box_work:/work"
RUN_OPTS+=" -v `pwd`:/hive-dev-box"
if [ "$TOOLBOX_SOURCES" != "" ];then
RUN_OPTS+=" -v $TOOLBOX_SOURCES:/toolbox"
fi
if [ "$DISPLAY" != "" ];then
echo " * enabling X forward..."
if [ "`which sw_vers`" != "" ] ; then
# MacOSX assumed
xhost + 127.0.0.1
RUN_OPTS+=" -e DISPLAY=host.docker.internal:0"
else
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
RUN_OPTS+=" -e DISPLAY -e XAUTHORITY=$XAUTH -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH"
fi
fi
if [ "$SSH_AUTH_SOCK" != "" ];then
echo " * enabling SSH_AUTH_SOCK"
RUN_OPTS+=" -v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
fi
RUN_OPTS+=" -v `pwd`/settings.xml:/home/dev/.m2/settings.xml"
RUN_OPTS+=" -v $HOME/.ssh:/home/dev/.ssh"
RUN_OPTS+=" -v $HOME/.gitconfig:/home/dev/.gitconfig"
RUN_OPTS+=" -e TERM=$TERM"
[ "$HIVE_DEV_BOX_HOST_DIR" != "" ] && RUN_OPTS+=" -v $HIVE_DEV_BOX_HOST_DIR:/home/dev/host"
[ "$HIVE_SOURCES" != "" ] && RUN_OPTS+=" -v $HIVE_SOURCES:/home/dev/hive"
[ -e "$HOME/.config/asf_toolbox.yml" ] && RUN_OPTS+=" -v $HOME/.config/asf_toolbox.yml:/home/dev/.config/asf_toolbox.yml"
[ -e "$HOME/.config/srcs.dsl" ] && RUN_OPTS+=" -v $HOME/.config/srcs.dsl:/home/dev/.config/srcs.dsl"
[ -e /var/run/docker.sock ] && RUN_OPTS+=" -v /var/run/docker.sock:/var/run/docker.sock"
# link artifactory
[ "`docker ps -q -f name=artifactory`" != "" ] && RUN_OPTS+=" --link artifactory:artifactory "
NET=hive-dev-box-net
RUN_OPTS+=" --network $NET"
RUN_OPTS+=" --shm-size 2g"
#RUN_OPTS+=" --security-opt seccomp=unconfined"
RUN_OPTS+=" --security-opt seccomp=seccomp.json"
HDB_TYPE=${HDB_TYPE:-hive}
IMG_NAME=${HDB_TYPE}-dev-box
case "${HDB_TYPE}" in
hive)
;;
impala)
BUILD_OPTS+=" -f Dockerfile.$HDB_TYPE"
RUN_OPTS+=" --privileged"
;;
*)
echo "invalid type $HDB_TYPE"
exit 1;
;;
esac
BUILD_OPTS+=" -t $IMG_NAME"
BUILD_OPTS+=" -t $IMG_NAME:`date +%s`"
#docker pull debian:buster
docker build $BUILD_OPTS .
docker network create $NET || true
docker run \
$RUN_OPTS \
"$@" \
$IMG_NAME \
/bin/bash