drone.yml 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. kind: pipeline # 定义对象类型,还有secret和signature两种类型
  2. type: docker # 定义流水线类型,还有kubernetes、exec、ssh等类型
  3. name: veterans_teacher # 定义流水线名称
  4. steps: # 定义流水线执行步骤,这些步骤将顺序执行
  5. - name: package # 流水线名称
  6. image: node:14.17.4-stretch-slim # 定义创建容器的Docker镜像
  7. volumes: #将容器内目录挂载到宿主机,仓库需要开启Trusted设置
  8. - name: node-cache
  9. path: /drone/src/node_modules
  10. - name: node-build
  11. path: /tmp
  12. commands: # 定义在Docker容器中执行的shell命令
  13. - npm install --registry=https://registry.npmmirror.com/ # 应用打包命令
  14. - npm run build
  15. - mkdir -p /tmp/veterans_teacher/dist
  16. - cp -r dist/* /tmp/veterans_teacher/dist
  17. - name: deploy
  18. image: appleboy/drone-ssh # SSH工具镜像
  19. settings:
  20. host: 172.16.90.64 # 远程连接地址
  21. username: root # 远程连接账号
  22. password:
  23. from_secret: 64_ssh_pw # 从Secret中读取SSH密码
  24. port: 22 # 远程连接端口
  25. command_timeout: 5m # 远程执行命令超时时间
  26. script:
  27. - mv /www/wwwroot/veteransteacher/ /tmp/$(uuidgen)
  28. - mkdir -p /www/wwwroot/veteransteacher
  29. - cp -r /mydata/node/build/veterans_teacher/dist/* /www/wwwroot/veteransteacher # 进入宿主机构建目录
  30. volumes:
  31. # 定义流水线挂载目录,用于共享数据
  32. - name: node-cache
  33. host:
  34. path: /mydata/node/cache/14/
  35. - name: node-build
  36. # 从宿主机中挂载的目录
  37. host:
  38. path: /mydata/node/build