.drone.yml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. kind: pipeline
  2. type: docker
  3. name: dev
  4. node:
  5. mode: local_test
  6. steps:
  7. - name: yarn-install
  8. image: node:18.16.1
  9. volumes:
  10. - name: modules-cache
  11. path: /drone/src/node_modules # 下载依赖的目录挂载出来,防止重复下载
  12. commands:
  13. - npm install -g pnpm
  14. # - pnpm config set registry http://registry.npmjs.org
  15. # - pnpm install
  16. - pnpm run build
  17. - name: build
  18. image: docker:20.10.7
  19. depends_on: [yarn-install]
  20. volumes:
  21. - name: docker
  22. path: /var/run/docker.sock
  23. environment:
  24. IMAGE: registry.yingcaibx.com/tl/admin_web:latest
  25. commands:
  26. # 清理 docker 服务中不再使用的镜像、挂载、网络等资源
  27. - docker system prune --force --volumes || true
  28. - docker build -f ./Dockerfile -t $IMAGE ./
  29. - name: run
  30. image: docker/compose
  31. depends_on: [build]
  32. volumes:
  33. - name: docker
  34. path: /var/run/docker.sock
  35. commands:
  36. - docker-compose -f docker-compose-dev.yml up -d
  37. trigger:
  38. branch:
  39. - dev
  40. event:
  41. - push
  42. volumes:
  43. - name: docker
  44. host:
  45. path: /var/run/docker.sock
  46. - name: modules-cache
  47. host:
  48. path: /data/cache/tl/new_web
  49. ---
  50. kind: pipeline
  51. type: docker
  52. name: pre
  53. node:
  54. mode: local_pre
  55. steps:
  56. - name: yarn-install
  57. image: node:18.16.1
  58. volumes:
  59. - name: modules-cache
  60. path: /drone/src/node_modules # 下载依赖的目录挂载出来,防止重复下载
  61. commands:
  62. # - pnpm config set registry http://registry.npmjs.org
  63. - npm install -g pnpm
  64. # - pnpm install
  65. - pnpm run build
  66. - name: build
  67. image: docker:20.10.7
  68. depends_on: [yarn-install]
  69. volumes:
  70. - name: docker
  71. path: /var/run/docker.sock
  72. environment:
  73. IMAGE: registry.yingcaibx.com/tl/admin_web:latest
  74. commands:
  75. # 清理 docker 服务中不再使用的镜像、挂载、网络等资源
  76. - docker system prune --force --volumes || true
  77. - docker build -f ./Dockerfile -t $IMAGE ./
  78. - name: run
  79. image: docker/compose
  80. depends_on: [build]
  81. volumes:
  82. - name: docker
  83. path: /var/run/docker.sock
  84. commands:
  85. - docker-compose -f docker-compose-pre.yml up -d
  86. trigger:
  87. branch:
  88. - pre
  89. event:
  90. - push
  91. volumes:
  92. - name: docker
  93. host:
  94. path: /var/run/docker.sock
  95. - name: modules-cache
  96. host:
  97. path: /data/cache/tl/web_new
  98. ---
  99. kind: pipeline
  100. type: docker
  101. name: release
  102. node:
  103. mode: local_test
  104. steps:
  105. - name: yarn-install
  106. depends_on: [clone]
  107. image: node:18.16.1
  108. volumes:
  109. - name: modules-cache
  110. path: /drone/src/node_modules # 下载依赖的目录挂载出来,防止重复下载
  111. commands:
  112. - npm install -g pnpm
  113. # - pnpm install
  114. - pnpm run build
  115. # - yarn install && yarn run build
  116. - name: push
  117. image: docker:20.10.7
  118. depends_on: [yarn-install]
  119. volumes:
  120. - name: docker
  121. path: /var/run/docker.sock
  122. environment:
  123. IMAGE: registry.yingcaibx.com/tl/admin_web
  124. commands:
  125. - docker login -u yxt -p qwe123QWE registry.yingcaibx.com
  126. - echo $DRONE_TAG
  127. - docker build -f ./Dockerfile -t $IMAGE:$DRONE_TAG ./
  128. - docker push $IMAGE:$DRONE_TAG
  129. - docker rmi $IMAGE:$DRONE_TAG
  130. trigger:
  131. event:
  132. - tag
  133. volumes:
  134. - name: docker
  135. host:
  136. path: /var/run/docker.sock
  137. - name: modules-cache
  138. host:
  139. path: /data/cache/tl/web