-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-build.sh
executable file
·93 lines (80 loc) · 1.65 KB
/
docker-build.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
89
90
91
92
93
#!/bin/bash
#
# recipes/ldms-samp/docker-build.sh
USAGE=$( cat <<EOF
./docker-build.sh [--ovis PATH]
EOF
)
# script dir
SCRIPT_DIR=$(dirname $0)
cd ${SCRIPT_DIR}
SCRIPT_DIR=${PWD}
# Work from the top src dir
cd ${SCRIPT_DIR}/../../
NAME=ovishpc/ldms-samp
source config.sh
if [[ -t 1 ]]; then
# Enable color for terminal
RST='\e[0m'
RED='\e[31m'
YLW='\e[33m'
fi
# Simple logging functions
_LOG() {
local _TS=$(date -Iseconds)
echo -e $(date -Iseconds) "$@"
}
_INFO() {
_LOG "${YLW}INFO:${RST}" "$@"
}
_ERROR() {
_LOG "${RED}ERROR:${RST}" "$@"
}
_ERROR_EXIT() {
_ERROR "$@"
exit -1
}
# convert --arg=value to --arg "value"
ARGS=( )
for X in "$@"; do
if [[ "$X" == --*=* ]]; then
ARGS+=( "${X%%=*}" "${X#*=}" )
else
ARGS+=( "$X" )
fi
done
set -- "${ARGS[@]}"
while (($#)); do
case "$1" in
--ovis)
shift
OVIS=$1
;;
*)
cat <<<"$USAGE"
exit -1
;;
esac
shift
done
[[ -n "${OVIS}" ]] || _ERROR_EXIT "--ovis PATH is required"
[[ -e "${OVIS}" ]] || _ERROR_EXIT "'${OVIS}' ovis directory does not exist."\
"Please build it with 'scripts/build-ovis-binaries.sh'"
[[ -d "${OVIS}" ]] || _ERROR_EXIT "'${OVIS}' is not a directory"
OVIS_LIBS=($(
cd ${OVIS} ; ls lib/lib* | grep -Ev 'lib(key|sos|dsos|idx|ods|tirpc)'
))
LDMS_LIBS=($(
cd ${OVIS} ; ls lib/ovis-ldms/* | grep -Ev 'libstore'
))
[[ -z "${BUILD_TAG}" ]] || NAME="${NAME}:${BUILD_TAG}"
_INFO "Building docker image: ${NAME}"
CTXT_DIR=${SCRIPT_DIR}/context
mkdir -p ${CTXT_DIR}
rm -rf ${CTXT_DIR}/*
pushd ${OVIS}
tar -c bin sbin ${OVIS_LIBS[*]} ${LDMS_LIBS[*]} \
lib/python*/site-packages etc \
-C ${SCRIPT_DIR} Dockerfile | tar -C ${CTXT_DIR} -x
pushd ${CTXT_DIR}
docker build -t ${NAME} .