首页 > 其他分享 >滚动部署docker服务

滚动部署docker服务

时间:2022-11-19 17:12:30浏览次数:50  
标签:滚动 部署 pro project ssh zhiying docker swagger

#!/bin/bash
set -x
KL_FILE="/opt/pro_swagger/project/kl-project/kl-project-zhiying/kl-project-zhiying-c-swagger/target/kl-project-zhiying-c-swagger-1.0.0-SNAPSHOT.jar"
KL_DIR="/opt/pro_swagger/project/kl-project/kl-project-zhiying/kl-project-zhiying-c-swagger/target/"
JAR_NAME="kl-project-zhiying-c-swagger-1.0.0-SNAPSHOT.jar"
TAG=`date +%Y%m%d_%H`
cd 

if [ -f "$KL_FILE"  ]
    then
    cd  $KL_DIR
    deploy_file=`ls | grep jar$`
else
    echo "JAR FILE NO EXIST"
        exit 100
fi
cd  $KL_DIR
pwd

cat << EOF > pro-swagger_Dockerfile
FROM  fbff214414b1
ENV TZ=Asia/Shanghai
WORKDIR /opt/apps
ENV  JAVA_OPTS='-Xmx2g -Xms2g -Xss10m  -XX:+UseG1GC -Xloggc:/opt/swagger/gclog/gc.log  '
COPY   $deploy_file  /opt/apps
expose 9082
VOLUME ["/opt/apps/logs"]
CMD ["sh", "-c", "java \$JAVA_OPTS -XX:+UseG1GC -Xloggc:/data/logs/gc.log -jar /opt/apps/$deploy_file --server.port=9082  --spring.profiles.active=pro" ]
EOF
docker build -t harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG}  -f pro-swagger_Dockerfile  . 
docker push harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG} 
docker rmi -f harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG}
echo $TAG
echo "***********************images push sucess*************************"
echo "******start docker deploy ***"
ssh -p 2233 node1  "docker pull harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG}"
ssh -p 2233 node2  "docker pull harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG}"
node1_port=`ssh -p 2233 node1 "netstat -lntp |grep 9082"`
node2_port=`ssh -p 2233 node2 "netstat -lntp |grep 9082"`
if [ ! -z "$node1_port" ] && [ ! -z "$node2_port" ]
then
    ssh -p 2233 node1 "docker stop swagger-pro"
    ssh -p 2233 node1 "docker rm swagger-pro"
    ssh -p 2233 node1 "docker run -dit --name swagger-pro  --net=host -v /data/swagger/logs:/opt/apps/logs -p 9082:9082 -e TZ="Asia/Shanghai" -d harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG}"
    sleep 10s
    if [ ! -z "$node2_port" ]
    then
        ssh -p 2233 node2 "docker stop swagger-pro"
        ssh -p 2233 node2 "docker rm swagger-pro"
        ssh -p 2233 node2 "docker run -dit --name swagger-pro  --net=host -v /data/swagger/logs:/opt/apps/logs -p 9082:9082 -d harbor.kuailaizhiying.com/zhiying/swagger_pro:${TAG}"
        echo -e "\033[42;37m  deploy is ok  \033[0m"
    else
        echo "请检查node1服务是否正常"
    fi

else
    echo "is swagger  no ha  runing"
fi

 

标签:滚动,部署,pro,project,ssh,zhiying,docker,swagger
From: https://www.cnblogs.com/niwajiang1/p/16906493.html

相关文章

  • ASP.NET Core 6部署到IIS
    1.打开IIS,新建一个网站2.给新创建的应用程序池,设置为无托管代码,下面那个选经典或集成好像都没问题 3.运行网站,不出意外的话,会报错,提示HTTP错误500.19,说明网站目录权......
  • Tomcat_关闭、部署项目的方式
    Tomcat_关闭关闭: 1.正常关闭:bin/shutdown.batctrl+c 2.强制关闭:点击启动窗口的× Tomcat_部署项目的方式配置:部署项目的方......
  • Docker Host '172.17.0.1' is blocked because of many connection errors; unblock w
    产生的原因是:同一个ip在短时间内产生太多(超过mysql数据库max_connect_errors的最大值)中断的数据库连接而导致的阻塞   解决方法:使用mysqladminflush-hosts命令清......
  • 使用 vlmcsd 部署 KMS 服务器
     一、前言:vlmcsd就是一个仿真KMS管理工具,可以部署在内网或者公网可以运行在Linux、Windows等系统平台上。 由于WindowsVL都是为批量激活而诞生,KMS服务器的作用......
  • springboot热部署
    <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional>......
  • docker卷管理
     这里使用server12yuminstallnfs-utils-y 保证打开服务rpcbindmkdir/mnt/nfs  server1vim/etc/exports/mnt/nfs  *(rw,no_root_squash) 或者改为777权限chm......
  • docker制作镜像、搭建私有仓库registry
    dockerrun-ti --rm--rm运行完自动删除容器是相对隔绝,和物理机共享内核 uname-rdockerinspect  namedocker分层可以节省空间,因为相同层数的镜像内容是只读共享的,......
  • 云原生之旅 - 12)使用 Kaniko 在 Kubernetes上构建 Docker 容器镜像
    前言前一篇文章【云原生之旅-11)基于Kubernetes动态伸缩JenkinsBuildAgents】有讲到在 KubernetesPod(Jenkinsbuildagent)里面构建docker容器镜像,当时我们......
  • 关于Docker安装后运行提示Cannot connect to the Docker daemon at unix:///var/run/d
    问题:执行如下命令即可:systemctldaemon-reloadsystemctlrestartdocker.service ......
  • PythonAnywhere 部署Flas项目
    一、注册账号官网:https://www.pythonanywhere.com/ 二、将GitHub上的项目发送至PythonAnywhere三、配置环境及运行gitclonehttps://github.com/chao-yua......