.drone.yml 3.3 KB

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