yd-yunxing-web/.drone.yml

47 lines
1.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

kind: pipeline # 定义对象类型还有secret和signature两种类型
type: docker # 定义流水线类型还有kubernetes、exec、ssh等类型
name: yd-yunxing-web # 服务名
steps:
- name: package # 流水线名称
image: node:18.20.4
volumes:
- name: bulid-workspace
path: /home/app/web
- name: node_modules
path: /root/node_modules
commands:
- npm config set registry https://registry.npmmirror.com
# - npm config set registry https://registry.npm.taobao.org
# - SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass
- npm install
- npm run build:prod
- rm -rf /home/app/web/dist || true # 如果存在就删除(忽略错误)
- mkdir -p /home/app/web/dist
- cp -r ./dist-prod /home/app/web/dist
- cp Dockerfile /home/app/web/Dockerfile
- cp docker.sh /home/app/web/docker.sh
- cp nginx.conf /home/app/web/nginx.conf
- name: build-start
image: appleboy/drone-ssh # SSH工具镜像
settings:
host: 192.168.0.31 # 远程连接地址
username: root # 远程连接账号
password: ybxm12345@ # 远程连接密码
# from_secret: dy20090625 # 从Secret中读取SSH密码
port: 9085 # 远程连接端口
command_timeout: 5m # 远程执行命令超时时间
script:
- cd /home/app/web # 进入宿主机构建目录
- chmod +x docker.sh # 更改为可执行脚本
- ./docker.sh # 运行脚本打包应用镜像并运行
volumes: # 定义流水线挂载目录,用于共享数据
- name: bulid-workspace
host:
path: /home/app/web # 从宿主机中挂载的目录
- name: node_modules
host:
path: /root/node_modules