21 if [[ ${NAME} && ${VERSION} && ${DIR} ]]; then
22 echo "assign the x to all files and dirs under current dir.."
24 echo "begin to build image ${NAME}.."
26 if [ $http_proxy ]; then
27 build_args+=" --build-arg http_proxy=$http_proxy"
29 if [ $https_proxy ]; then
30 build_args+=" --build-arg https_proxy=$https_proxy"
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
38 mv ${NAME}.tar ${DIR}/${NAME}.tar &>/dev/null
39 echo "build completes!"
41 echo "not all -n and -v and -d are provided!"