pipeline-convert/build.sh

56 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
if [ -e "pipeline-convert" ];then
rm pipeline-convert
fi
echo "################### build start ###################"
#docker run -v /data/nfs/gocache:/go -v /mnt/e/复杂计算平台资料/code/pipeline-convert/:/code ccr.ccs.tencentyun.com/somunslotus/pipeline-covert:develop-env sh -c "cd /code && go build"
docker run -v /data/nfs/gocache:/go -v /home/somuns/code/:/code -e http_proxy=http://172.20.32.253:3128 -e https_proxy=http://172.20.32.253:3128 ccr.ccs.tencentyun.com/somunslotus/pipeline-covert:develop-env sh -c "cd /code && go build"
if [ "$?" -ne "0" ];then
echo "build fail"
exit 1
fi
echo "################### build end ###################"
tag=$(date +'%Y%m%d%H%M')
image=ccr.ccs.tencentyun.com/somunslotus/pipeline-covert:${tag}
#image=somunslotus/pipeline-convert:${tag}
echo "image is ${image}"
echo "################### build image start ###################"
docker build -t ${image} .
if [ "$?" -ne "0" ];then
echo "make image fail"
exit 2
fi
echo "################### build image end ###################"
echo "################### push image start ###################"
docker push ${image}
if [ "$?" -ne "0" ];then
echo "push image fail"
exit 3
fi
echo "################### push image end ###################"
sed -i "s#pipeline-image#${image}#g" pipeline-convert.yaml
if [ "$?" -ne "0" ];then
echo "replace image fail"
exit 4
fi
echo "################### deploy start ###################"
scp pipeline-convert.yaml root@172.20.32.181:/home/deploy/script/pipeline-convert/pipeline-convert.yaml
ssh root@172.20.32.181 "unset http_proxy && unset https_proxy && kubectl apply -f /home/deploy/script/pipeline-convert/pipeline-convert.yaml"
sed -i "s#${image}#pipeline-image#g" pipeline-convert.yaml
if [ "$?" -ne "0" ];then
echo "deploy fail"
exit 5
fi
echo "################### deploy success ###################"