Solve jackson datatype security issue
[msb/apigateway.git] / ci / build_docker_image.sh
1 #!/bin/bash
2
3 for i in "$@"
4 do
5 case $i in
6     -n=*|--name=*)
7     NAME="${i#*=}"
8     shift
9     ;;
10     -v=*|--version=*)
11     VERSION="${i#*=}"
12     shift
13     ;;
14     -d=*|--dir=*)
15     DIR="${i#*=}"
16     shift
17     ;;
18 esac
19 done
20
21 if [[ ${NAME} && ${VERSION} && ${DIR} ]]; then
22         echo "assign the x to all files and dirs under current dir.."
23         chmod +x -R .
24         echo "begin to build image ${NAME}.."
25         build_args=""
26         if [ $http_proxy ]; then
27             build_args+=" --build-arg http_proxy=$http_proxy"
28         fi
29         if [ $https_proxy ]; then
30             build_args+=" --build-arg https_proxy=$https_proxy"
31         fi
32         docker build --no-cache -t ${NAME}:${VERSION} $build_args . >/dev/null || { echo -e "\nBuild docker image failed!";exit 1; }
33         docker rmi $(docker images | grep "^<none>" | awk '{print $3}') &>/dev/null
34         # docker save -o ${NAME}.tar ${NAME}:${VERSION} >/dev/null || { rm -f ${NAME}.tar &>/dev/null;echo -e "\nSave docker image failed!";exit 1; }
35         if [ ! -d ${DIR} ]; then
36                 mkdir -p ${DIR}
37         fi
38         mv ${NAME}.tar ${DIR}/${NAME}.tar &>/dev/null
39         echo "build completes!"
40 else
41         echo "not all -n and -v and -d are provided!"
42         exit 1
43 fi