.drone.yml 3.1 KB

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