From df69d980734a683d98407119a14e24fe37a03006 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Wed, 16 Oct 2024 14:48:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8C=82=E8=BD=BD=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-server/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yudao-server/run.sh b/yudao-server/run.sh index 3efe190..22aec29 100644 --- a/yudao-server/run.sh +++ b/yudao-server/run.sh @@ -13,4 +13,4 @@ docker rm ${app_name} #echo '----rm image----' #docker rmi -f "${app_name}:${app_version}" echo '----start container----' -docker run -d -p 6127:6127 --name ${app_name} --restart always "${app_repository}/${app_name}:${app_version}" \ No newline at end of file +docker run -d -p 6127:6127 --name ${app_name} -v /home/mallpic:/home/mallpic--restart always "${app_repository}/${app_name}:${app_version}" \ No newline at end of file From 8b801be4f3d90817831842fe3cc238e231efdc74 Mon Sep 17 00:00:00 2001 From: XinWei <2718030729@qq.com> Date: Wed, 16 Oct 2024 15:00:14 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone-build-image.yml | 69 ++++++++++++++++++++++++++++++++++++++++++ .drone.yml | 49 ++++++------------------------ yudao-server/all.sh | 16 ++++++++++ yudao-server/run.sh | 6 ++-- 4 files changed, 97 insertions(+), 43 deletions(-) create mode 100644 .drone-build-image.yml create mode 100644 yudao-server/all.sh diff --git a/.drone-build-image.yml b/.drone-build-image.yml new file mode 100644 index 0000000..6ac6a8e --- /dev/null +++ b/.drone-build-image.yml @@ -0,0 +1,69 @@ +kind: pipeline # 定义对象类型,还有secret和signature两种类型 + +type: docker # 定义流水线类型,还有kubernetes、exec、ssh等类型 + +name: filesystem-drone # 定义流水线名称 + +clone: + disable: true +steps: # 定义流水线执行步骤,这些步骤将顺序执行 + + - name: package-and-push-image + + image: appleboy/drone-ssh # SSH工具镜像 + + settings: + + host: 101.43.112.107 # 远程连接地址 + + username: root # 远程连接账号 + + password: + + from_secret: ssh_password # 从Secret中读取SSH密码 + + port: 22 # 远程连接端口 + + command_timeout: 10m # 远程执行命令超时时间 + + script: + - cd /root/allLikeMall + - git fetch origin + - git reset --hard origin/master + - git clean -fd + - /root/apache-maven-3.9.4/bin/mvn package -Dmaven.test.skip=true + - cd yudao-server + - chmod +x push.sh + - ./push.sh + - scp run.sh root@1.14.205.126:/zymail/build +# - ls +# - scp -r /zymail/maven/build root@1.14.205.126:/zymail +# - ssh root@1.14.205.126 +# - ls + +# - chmod +x run.sh # 更改为可执行脚本 + +# - ./run.sh # 运行脚本打包应用镜像并运行 + - name: build-start + + image: appleboy/drone-ssh # SSH工具镜像 + + settings: + + host: 1.14.205.126 # 远程连接地址 + + username: root # 远程连接账号 + + password: + + from_secret: ssh_password # 从Secret中读取SSH密码 + + port: 22 # 远程连接端口 + + command_timeout: 30m # 远程执行命令超时时间 + + script: +# - ls + - cd /zymail/build + - chmod +x run.sh # 更改为可执行脚本 + - ./run.sh # 运行脚本打包应用镜像并运行 diff --git a/.drone.yml b/.drone.yml index 6ac6a8e..ea9a568 100644 --- a/.drone.yml +++ b/.drone.yml @@ -8,42 +8,6 @@ clone: disable: true steps: # 定义流水线执行步骤,这些步骤将顺序执行 - - name: package-and-push-image - - image: appleboy/drone-ssh # SSH工具镜像 - - settings: - - host: 101.43.112.107 # 远程连接地址 - - username: root # 远程连接账号 - - password: - - from_secret: ssh_password # 从Secret中读取SSH密码 - - port: 22 # 远程连接端口 - - command_timeout: 10m # 远程执行命令超时时间 - - script: - - cd /root/allLikeMall - - git fetch origin - - git reset --hard origin/master - - git clean -fd - - /root/apache-maven-3.9.4/bin/mvn package -Dmaven.test.skip=true - - cd yudao-server - - chmod +x push.sh - - ./push.sh - - scp run.sh root@1.14.205.126:/zymail/build -# - ls -# - scp -r /zymail/maven/build root@1.14.205.126:/zymail -# - ssh root@1.14.205.126 -# - ls - -# - chmod +x run.sh # 更改为可执行脚本 - -# - ./run.sh # 运行脚本打包应用镜像并运行 - name: build-start image: appleboy/drone-ssh # SSH工具镜像 @@ -63,7 +27,12 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行 command_timeout: 30m # 远程执行命令超时时间 script: -# - ls - - cd /zymail/build - - chmod +x run.sh # 更改为可执行脚本 - - ./run.sh # 运行脚本打包应用镜像并运行 + - cd /root/allLikeMall + - git fetch origin + - git reset --hard origin/master + - git clean -fd + - /root/apache-maven-3.9.4/bin/mvn package -Dmaven.test.skip=true + - cd yudao-server + - chmod +x all.sh + - ./all.sh + diff --git a/yudao-server/all.sh b/yudao-server/all.sh new file mode 100644 index 0000000..61511ea --- /dev/null +++ b/yudao-server/all.sh @@ -0,0 +1,16 @@ +#!/bin/bash +app_name='zymall' +# 定义应用版本 +app_version='1.0.0' +# 定义应用环境 +# 打包编译docker镜像 +echo '----build image----' +docker buildx build -f Dockerfile -t "${app_name}:${app_version}" . +echo '----stop container----' +docker stop ${app_name} +echo '----rm container----' +docker rm ${app_name} +echo '----rmi none image----' +docker rmi $(docker images -f "dangling=true" -q) +echo '----start container----' +docker run -d -p 6127:6127 --name ${app_name} -v /home/mallpic:/home/mallpic --restart always ${app_name}:${app_version} \ No newline at end of file diff --git a/yudao-server/run.sh b/yudao-server/run.sh index 22aec29..735a996 100644 --- a/yudao-server/run.sh +++ b/yudao-server/run.sh @@ -10,7 +10,7 @@ echo '----stop container----' docker stop ${app_name} echo '----rm container----' docker rm ${app_name} -#echo '----rm image----' -#docker rmi -f "${app_name}:${app_version}" +echo '----rmi none image----' +docker rmi $(docker images -f "dangling=true" -q) echo '----start container----' -docker run -d -p 6127:6127 --name ${app_name} -v /home/mallpic:/home/mallpic--restart always "${app_repository}/${app_name}:${app_version}" \ No newline at end of file +docker run -d -p 6127:6127 --name ${app_name} -v /home/mallpic:/home/mallpic --restart always "${app_repository}/${app_name}:${app_version}" \ No newline at end of file