-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.sh
41 lines (35 loc) · 1.18 KB
/
common.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
#
# Set up a docker network
DOCKER_NETWORK=docker
docker network create -d bridge --subnet 172.20.0.0/16 ${DOCKER_NETWORK}
# Return (echo) the base path to developers source repositorys
function get_code_path {
EDUID_SRC_PATH=${EDUID_SRC_PATH-'~/work/NORDUnet'}
echo "`eval echo ${EDUID_SRC_PATH//>}`" # handle '>' in EDUID_SRC_PATH
}
#
# Figure out suitable 'docker run' parameters to volume-mount in any present
# source code for this container, and an according PYTHONPATH to the volumes
function get_developer_params {
host_src_path="$(echo $(get_code_path))"
guest_src_path="/opt/eduid/src"
src_volumes=""
pp=""
for name in $*; do
srcdir="${host_src_path}/${name}"
if [ -d "${srcdir}" ]; then
if [ -d "${srcdir}/src" ]; then
# Some packages, like eduid-IdP, has the Python package in a src/ dir
srcdir+="/src"
fi
# map developers local source copy into /opt/eduid/src and set PYTHONPATH accordingly
src_volumes+=" -v ${srcdir}:${guest_src_path}/${name}"
if [ "x${pp}" = "x" ]; then
pp="--env=PYTHONPATH=${guest_src_path}/${name}"
else
pp+=":${guest_src_path}/${name}"
fi
fi
done
echo "${src_volumes} ${pp}"
}