.gitlab-ci.yml.bak 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. stages:
  2. - build
  3. - deploy
  4. build:
  5. stage: build
  6. tags:
  7. - "srv100"
  8. only:
  9. - "auto-deploy"
  10. script:
  11. - export PROJECT='business-webapi'
  12. - export TAG='v1.0.0.'$(date +%s)
  13. - export IMAGE_NAME='registry.cn-hangzhou.aliyuncs.com/ggcimages/hzhs-deploy:business-webapi--'
  14. - (sh -c "echo 'PROJECT='${PROJECT}', TAG='${TAG}', IMAGE_NAME='${IMAGE_NAME}")
  15. # 通过 docker compose 编译和构建容器镜像
  16. - chmod +x .gitlab-ci-help.sh && sh ./.gitlab-ci-help.sh
  17. - (sh -c "docker compose -f docker-compose.yml -p ${PROJECT} build") || echo '构建容器失败!'
  18. # 通过 docker compose 停止在运行容器
  19. - (sh -c "docker compose -f docker-compose.yml -p ${PROJECT} down ") || echo '移除容器失败!'
  20. # 通过 docker compose 重启和发布容器
  21. #- (sh -c "docker compose -f docker-compose.yml -p ${PROJECT} up -d ") || echo '启动容器失败!'
  22. # 发布容器镜像到阿里云
  23. - (sh -c "docker push ${IMAGE_NAME}${TAG}") || echo '推送镜像到阿里云失败!'
  24. #artifacts:
  25. #paths:
  26. #- target/*.jar
  27. #build:
  28. # stage: build
  29. # tags:
  30. # - srv150
  31. # only:
  32. # - 1.0.X
  33. # script:
  34. # - export PROJECT='business-webapi'
  35. # - export TAG='v1.0.0.'$(date +%s)
  36. # - export CONTAINTER='business-webapi'
  37. # - (sh -c "sudo podman stop business-webapi") || echo '停止容器失败!'
  38. # - (sh -c "sudo podman rm business-webapi" && rm /root/podman_cron.d/${CONTAINTER}) || echo '移除容器失败!'
  39. # - (sh -c "sudo podman rmi business-webapi") || echo '移除镜像失败!'
  40. # - (sh -c "sudo podman build -t localhost/business-webapi . && echo '构建镜像成功!'") || echo '构建镜像失败!'
  41. # - (sh -c "sudo podman run -d -p 172.16.10.150:8105:8105 -e PROFILE=test --name ${CONTAINTER} localhost/business-webapi >${CONTAINTER}")
  42. # - echo '当前容器ID:'$(cat ${CONTAINTER})
  43. # - (sh -c "sudo mv ${CONTAINTER} /root/podman_cron.d/${CONTAINTER}")
  44. # - (sh -c "sudo podman logs --tail 200 ${CONTAINTER}")
  45. # #artifacts:
  46. # #paths:
  47. # #- target/*.jar
  48. #
  49. #deploy:
  50. # stage: deploy
  51. # when: manual
  52. # tags:
  53. # - hz3r
  54. # only:
  55. # - main
  56. # - 1.0.x
  57. # script:
  58. # - rm -rf /data/img-data/business-webapi.img
  59. # - podman save business-webapi:latest -o /data/img-data/business-webapi.img
  60. #
  61. #webgis-geoserver-build:
  62. # stage: build
  63. # when: manual
  64. # tags:
  65. # - hz3r
  66. # only:
  67. # - main
  68. # - 1.0.x
  69. # script:
  70. # - systemctl disable container-business-webgis-geoserver.service
  71. # - systemctl stop container-business-webgis-geoserver.service
  72. # - rm -rf /etc/systemd/system/container-business-webgis-geoserver.service
  73. # - podman rm business-webgis-geoserver
  74. # - podman rmi business-webgis-geoserver:test
  75. # - podman build -t business-webgis-geoserver:test -f /data/projects/business/business-webgis-geoserver/Dockerfile-test /data/projects/business/business-webgis-geoserver
  76. # - podman run -d -p 172.16.10.100:8098:8888 --name business-webgis-geoserver business-webgis-geoserver:test
  77. # - podman logs --tail 200 business-webgis-geoserver
  78. # - podman stop -t 60 business-webgis-geoserver
  79. # - podman generate systemd -n -t 60 -f business-webgis-geoserver
  80. # - mv container-business-webgis-geoserver.service /etc/systemd/system
  81. # - systemctl enable container-business-webgis-geoserver.service
  82. # - systemctl start container-business-webgis-geoserver.service
  83. # - podman logs --tail 200 business-webgis-geoserver
  84. #
  85. #webgis-geoserver-deploy:
  86. # stage: deploy
  87. # when: manual
  88. # tags:
  89. # - hz3r
  90. # only:
  91. # - main
  92. # - 1.0.x
  93. # script:
  94. # - podman build -t business-webgis-geoserver:prod -f /data/projects/business/business-webgis-geoserver/Dockerfile-prod /data/projects/business/business-webgis-geoserver
  95. # - rm -rf /data/img-data/business-webgis-geoserver.img
  96. # - podman save business-webgis-geoserver:prod -o /data/img-data/business-webgis-geoserver.img
  97. #
  98. #webgis-service-build:
  99. # stage: build
  100. # when: manual
  101. # tags:
  102. # - hz3r
  103. # only:
  104. # - main
  105. # - 1.0.x
  106. # script:
  107. # - systemctl disable container-business-webgis-service.service
  108. # - systemctl stop container-business-webgis-service.service
  109. # - rm -rf /etc/systemd/system/container-business-webgis-service.service
  110. # - podman rm business-webgis-service
  111. # - podman rmi business-webgis-service:test
  112. # - podman build -t business-webgis-service:test -f /data/projects/business/business-webgis-service/Dockerfile-test /data/projects/business/business-webgis-service
  113. # - podman run -d -p 172.16.10.100:19598:19598 --name business-webgis-service business-webgis-service:test
  114. # - podman logs --tail 200 business-webgis-service
  115. # - podman stop -t 60 business-webgis-service
  116. # - podman generate systemd -n -t 60 -f business-webgis-service
  117. # - mv container-business-webgis-service.service /etc/systemd/system
  118. # - systemctl enable container-business-webgis-service.service
  119. # - systemctl start container-business-webgis-service.service
  120. # - podman logs --tail 200 business-webgis-service
  121. #
  122. #webgis-service-deploy:
  123. # stage: deploy
  124. # when: manual
  125. # tags:
  126. # - hz3r
  127. # only:
  128. # - main
  129. # - 1.0.x
  130. # script:
  131. # - podman build -t business-webgis-service:prod -f /data/projects/business/business-webgis-service/Dockerfile-prod /data/projects/business/business-webgis-service
  132. # - rm -rf /data/img-data/business-webgis-service.img
  133. # - podman save business-webgis-service:prod -o /data/img-data/business-webgis-service.img
  134. #
  135. #webgis-spatial-build:
  136. # stage: build
  137. # when: manual
  138. # tags:
  139. # - hz3r
  140. # only:
  141. # - main
  142. # - 1.0.x
  143. # script:
  144. # - systemctl disable container-business-webgis-spatial.service
  145. # - systemctl stop container-business-webgis-spatial.service
  146. # - rm -rf /etc/systemd/system/container-business-webgis-spatial.service
  147. # - podman rm business-webgis-spatial
  148. # - podman rmi business-webgis-spatial:test
  149. # - podman build -t business-webgis-spatial:test -f /data/projects/business/business-webgis-spatial/Dockerfile-test /data/projects/business/business-webgis-spatial
  150. # - podman run -d -p 172.16.10.100:8099:8099 --name business-webgis-spatial business-webgis-spatial:test
  151. # - podman logs --tail 200 business-webgis-spatial
  152. # - podman stop -t 60 business-webgis-spatial
  153. # - podman generate systemd -n -t 60 -f business-webgis-spatial
  154. # - mv container-business-webgis-spatial.service /etc/systemd/system
  155. # - systemctl enable container-business-webgis-spatial.service
  156. # - systemctl start container-business-webgis-spatial.service
  157. # - podman logs --tail 200 business-webgis-spatial
  158. #
  159. #webgis-spatial-deploy:
  160. # stage: deploy
  161. # when: manual
  162. # tags:
  163. # - hz3r
  164. # only:
  165. # - main
  166. # - 1.0.x
  167. # script:
  168. # - podman build -t business-webgis-spatial:prod -f /data/projects/business/business-webgis-spatial/Dockerfile-prod /data/projects/business/business-webgis-spatial
  169. # - rm -rf /data/img-data/business-webgis-spatial.img
  170. # - podman save business-webgis-spatial:prod -o /data/img-data/business-webgis-spatial.img