Compare commits

...

4 Commits

Author SHA1 Message Date
a6a1ab163d Merge pull request 'cxw' (#48) from cxw into master
All checks were successful
continuous-integration/drone Build is passing
Reviewed-on: #48
2024-10-16 15:06:54 +08:00
9860ff79d5 Merge branch 'master' of http://101.43.112.107:3000/root/allLikeMall into cxw 2024-10-16 15:03:29 +08:00
8b801be4f3 构建脚本调整 2024-10-16 15:00:14 +08:00
df69d98073 挂载本地图片路径 2024-10-16 14:48:58 +08:00
4 changed files with 97 additions and 43 deletions

69
.drone-build-image.yml Normal file
View File

@ -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 # 运行脚本打包应用镜像并运行

View File

@ -8,42 +8,6 @@ clone:
disable: true disable: true
steps: # 定义流水线执行步骤,这些步骤将顺序执行 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 - name: build-start
image: appleboy/drone-ssh # SSH工具镜像 image: appleboy/drone-ssh # SSH工具镜像
@ -63,7 +27,12 @@ steps: # 定义流水线执行步骤,这些步骤将顺序执行
command_timeout: 30m # 远程执行命令超时时间 command_timeout: 30m # 远程执行命令超时时间
script: script:
# - ls - cd /root/allLikeMall
- cd /zymail/build - git fetch origin
- chmod +x run.sh # 更改为可执行脚本 - git reset --hard origin/master
- ./run.sh # 运行脚本打包应用镜像并运行 - 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

16
yudao-server/all.sh Normal file
View File

@ -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}

View File

@ -10,7 +10,7 @@ echo '----stop container----'
docker stop ${app_name} docker stop ${app_name}
echo '----rm container----' echo '----rm container----'
docker rm ${app_name} docker rm ${app_name}
#echo '----rm image----' echo '----rmi none image----'
#docker rmi -f "${app_name}:${app_version}" docker rmi $(docker images -f "dangling=true" -q)
echo '----start container----' echo '----start container----'
docker run -d -p 6127:6127 --name ${app_name} --restart always "${app_repository}/${app_name}:${app_version}" docker run -d -p 6127:6127 --name ${app_name} -v /home/mallpic:/home/mallpic --restart always "${app_repository}/${app_name}:${app_version}"