forked from intel/vtpm-td
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.sh
executable file
·58 lines (47 loc) · 1.15 KB
/
docker.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
#!/bin/bash
set -e
FOLDER=""
usage() {
cat << EOM
Usage: $(basename "$0") [OPTION]...
-d <docker file> Path of Dockerfile.
EOM
}
error() {
echo -e "\e[1;31mERROR: $*\e[0;0m"
exit 1
}
process_args() {
while getopts ":f:h" option; do
case "$option" in
f) FOLDER=$OPTARG;;
h) usage
exit 0
;;
*)
echo "Invalid option '-$OPTARG'"
usage
exit 1
;;
esac
done
if [[ -z ${FOLDER} ]]; then
error "Please specify the folder of where the Dockerfile is located through -f."
fi
if [[ ! -f "${FOLDER}/Dockerfile" ]]; then
error "Dockerfile does not exist."
fi
}
process_args $@
pushd ${FOLDER}
# If the docker image does not exist, build the docker image
set +e && docker image inspect vtpmtd.build.env:latest > /dev/null 2>&1 && set -e
if [ $? != 0 ]; then
docker build -t vtpmtd.build.env \
--build-arg https_proxy=$https_proxy \
--build-arg http_proxy=$http_proxy \
.
fi
popd
# Run the docker image
docker run -it --rm vtpmtd.build.env