pipeline-convert/build_for_235.sh

75 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
if [[ -n "$1" && "$1" != "fast" ]]; then
echo "Invalid parameter: $1"
echo "Parameter must be 'fast' or empty"
exit 1
fi
start=$(date +%s)
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"
if [ "$1" == "" ];then
echo "nomal build"
docker run -v /data/nfs/gocache:/go -v $(pwd):/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-go1.22.2 sh -c "cd /code && go build"
fi
if [ "$1" == "fast" ];then
echo "fast build"
docker exec -ti go-compile sh -c "rm -rf pipeline-covert && go mod tidy && go build"
fi
if [ "$?" -ne "0" ];then
echo "build fail"
exit 1
fi
echo "################### build end ###################"
tag=$(date +'%Y%m%d%H%M')
image=172.20.32.187/pipeline-service/pipeline-convert:${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.235:/home/deploy/script/pipeline-convert/pipeline-convert.yaml
ssh root@172.20.32.235 "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-debug.yaml
if [ "$?" -ne "0" ];then
echo "deploy fail"
exit 5
fi
echo "################### deploy success ###################"
end=$(date +%s)
echo "build and deploy success, cost time: $((end-start))s"