forked from kgyrtkirk/hive-dev-box
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bash
More file actions
executable file
·64 lines (53 loc) · 1.85 KB
/
run.bash
File metadata and controls
executable file
·64 lines (53 loc) · 1.85 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
60
61
62
63
#!/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
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"
BUILD_OPTS+=" -t hive-dev-box"
BUILD_OPTS+=" -t hive-dev-box:`date +%s`"
docker build $BUILD_OPTS .
docker network create $NET || true
docker run \
$RUN_OPTS \
"$@" \
hive-dev-box \
/bin/bash