Add swagger.json as discovery release artifacts
[msb/discovery.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         docker build --no-cache -t ${NAME}:${VERSION} . >/dev/null || { echo -e "\nBuild docker image failed!";exit 1; }
26         docker rmi $(docker images | grep "^<none>" | awk '{print $3}') &>/dev/null
27         # docker save -o ${NAME}.tar ${NAME}:${VERSION} >/dev/null || { rm -f ${NAME}.tar &>/dev/null;echo -e "\nSave docker image failed!";exit 1; }
28         # if [ ! -d ${DIR} ]; then
29         #       mkdir -p ${DIR}
30         # fi
31         # mv ${NAME}.tar ${DIR}/${NAME}.tar &>/dev/null
32         echo "build completes!"
33 else
34         echo "not all -n and -v and -d are provided!"
35         exit 1
36 fi