You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

325 lines
11 KiB

  1. #外部参数
  2. SERVER_BINARY_DIR=$(binary_dir)
  3. ifeq (${SERVER_BINARY_DIR}, )
  4. SERVER_BINARY_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/server/bin
  5. endif
  6. RELEASE_VER=$(tag)
  7. ifeq (${RELEASE_VER}, )
  8. RELEASE_VER=latest
  9. endif
  10. DOCKER_HUB_HOST=$(docker_hub_host)
  11. DOCKER_HUB_USERNAME=$(docker_hub_userame)
  12. DOCKER_HUB_PASSWD=$(docker_hub_passwd)
  13. DOCKER_HUB_PROJECT=$(docker_hub_project)
  14. HARBOR_HUB_HOST=$(harbor_hub_host)
  15. HARBOR_HUB_USERNAME=$(harbor_hub_userame)
  16. HARBOR_HUB_PASSWD=$(harbor_hub_passwd)
  17. HARBOR_HUB_PROJECT=$(harbor_hub_project)
  18. HARBOR_HUB_CA_FILE=$(harbor_hub_ca_file)
  19. HARBOR_HUB_CERT_FILE=$(harbor_hub_cert_file)
  20. NEED_LATEST=$(need_latest)
  21. CHARTS_GIT_DIR=./tmp/gitcharts
  22. CHARTS_GIT_CLONE=$(charts_git_clone)
  23. CHARTS_GIT_RAW=$(charts_git_raw)
  24. CHARTS_GIT_USER_NAME=$(charts_git_user_name)
  25. CHARTS_GIT_USER_EMAIL=$(charts_git_user_email)
  26. DRONE_REPO=$(drone_repo)
  27. # 静态变量
  28. Date=`date "+%Y-%m-%d %H:%M:%S"`
  29. LD_FLAGS=" \
  30. -X 'main.Built=${Date}' \
  31. -X 'main.Version=${RELEASE_VER}'"
  32. # 编译
  33. all_build: server_build
  34. server_build: base-server_build admin-server_build openai-server_build taskset_build
  35. init:
  36. mkdir -p ${SERVER_BINARY_DIR}
  37. base-server_build: init
  38. cd ./server && go generate
  39. cd ./server/base-server && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./...
  40. admin-server_build: init
  41. cd ./server && go generate
  42. cd ./server/admin-server && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./...
  43. openai-server_build: init
  44. cd ./server && go generate
  45. cd ./server/openai-server && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./...
  46. taskset_build: pipeline_build vc-controller_build scheduler_build
  47. pipeline_build: init
  48. cd ./server/taskset && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./main/pipeline
  49. vc-controller_build: init
  50. cd ./server/taskset && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./main/vc-controller
  51. scheduler_build: init
  52. cd ./server/taskset && go build -ldflags ${LD_FLAGS} -o ${SERVER_BINARY_DIR} ./main/scheduler
  53. api-doc_build: init
  54. cd ./server && go generate
  55. # 运行
  56. all_run: server_run
  57. server_run: base-server_run admin-server_run openai-server_run taskset_run
  58. base-server_run:
  59. cd server && ./bin/base-server -conf base-server/configs &
  60. admin-server_run:
  61. cd server && ./bin/admin-server -conf admin-server/configs &
  62. openai-server_run:
  63. cd server && ./bin/openai-server -conf openai-server/configs &
  64. taskset_run: pipeline_run vc-controller_run scheduler_run
  65. pipeline_run:
  66. cd server && ./bin/pipeline &
  67. vc-controller_run:
  68. cd server && ./bin/vc-controller &
  69. scheduler_run:
  70. cd server && ./bin/scheduler &
  71. # 停止
  72. all_stop: server_stop
  73. server_stop: base-server_stop admin-server_stop openai-server_stop taskset_stop
  74. base-server_stop:
  75. kill -9 `ps -ef|grep "base-server" |grep -v grep |awk '{print $2}'`
  76. admin-server_stop:
  77. kill -9 `ps -ef|grep "admin-server" |grep -v grep |awk '{print $2}'`
  78. openai-server_stop:
  79. kill -9 `ps -ef|grep "openai-server" |grep -v grep |awk '{print $2}'`
  80. taskset_stop: pipeline_stop vc-controller_stop scheduler_stop
  81. pipeline_stop:
  82. kill -9 `ps -ef|grep "pipeline" |grep -v grep |awk '{print $2}'`
  83. vc-controller_stop:
  84. kill -9 `ps -ef|grep "vc-controller" |grep -v grep |awk '{print $2}'`
  85. scheduler_stop:
  86. kill -9 `ps -ef|grep "scheduler" |grep -v grep |awk '{print $2}'`
  87. # 重启
  88. all_stop: server_restart
  89. server_restart: base-server_restart admin-server_restart openai-server_restart taskset_restart
  90. base-server_restart: base-server_stop server_run
  91. admin-server_restart: admin-server_stop admin-server_run
  92. openai-server_restart: openai-server_stop openai-server_run
  93. taskset_restart: pipeline_restart vc-controller_restart scheduler_restart
  94. pipeline_restart: pipeline_stop pipeline_run
  95. vc-controller_restart: vc-controller_stop vc-controller_run
  96. scheduler_restart: scheduler_stop scheduler_run
  97. # 代码检查
  98. lint_init:
  99. golangci-lint version
  100. lint: lint_init
  101. cd ./server && golangci-lint run ./...
  102. common_lint: lint_init
  103. cd ./server/common && golangci-lint run ./...
  104. base-server_lint: lint_init
  105. cd ./server/base-server && golangci-lint run ./...
  106. admin-server_lint: lint_init
  107. cd ./server/admin-server && golangci-lint run ./...
  108. openai-server_lint: lint_init
  109. cd ./server/openai-server && golangci-lint run ./...
  110. taskset_lint: lint_init
  111. cd ./server/taskset && golangci-lint run ./...
  112. # 构建镜像
  113. images: base-server_image admin-server_image openai-server_image taskset_image admin-portal_image openai-portal_image api-doc_image
  114. base-server_image:
  115. docker build --no-cache -t base-server:${RELEASE_VER} -f ./build/application/base-server/dockerfile .
  116. admin-server_image:
  117. docker build --no-cache -t admin-server:${RELEASE_VER} -f ./build/application/admin-server/dockerfile .
  118. openai-server_image:
  119. docker build --no-cache -t openai-server:${RELEASE_VER} -f ./build/application/openai-server/dockerfile .
  120. taskset_image: pipeline_image vc-controller_image scheduler_image
  121. pipeline_image:
  122. docker build --no-cache -t pipeline:${RELEASE_VER} -f ./build/application/taskset/pipeline/dockerfile .
  123. vc-controller_image:
  124. docker build --no-cache -t vc-controller:${RELEASE_VER} -f ./build/application/taskset/vc-controller/dockerfile .
  125. scheduler_image:
  126. docker build --no-cache -t scheduler:${RELEASE_VER} -f ./build/application/taskset/scheduler/dockerfile .
  127. admin-portal_image:
  128. docker build --no-cache -t admin-portal:${RELEASE_VER} -f ./build/application/admin-portal/dockerfile .
  129. openai-portal_image:
  130. docker build --no-cache -t openai-portal:${RELEASE_VER} -f ./build/application/openai-portal/dockerfile .
  131. api-doc_image:
  132. docker build --no-cache -t api-doc:${RELEASE_VER} -f ./build/application/api-doc/dockerfile .
  133. # 镜像推送
  134. images_push: base-server_image_push admin-server_image_push openai-server_image_push taskset_image_push admin-portal_image_push openai-portal_image_push api-doc_image_push
  135. image_push_init:
  136. (echo ${DOCKER_HUB_PASSWD} | docker login ${DOCKER_HUB_HOST} -u ${DOCKER_HUB_USERNAME} --password-stdin) 1>/dev/null 2>&1
  137. base-server_image_push: image_push_init
  138. docker tag base-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/base-server:${RELEASE_VER}
  139. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/base-server:${RELEASE_VER}
  140. ifneq (${RELEASE_VER}, latest)
  141. ifeq (${NEED_LATEST}, TRUE)
  142. docker tag base-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/base-server:latest
  143. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/base-server:latest
  144. endif
  145. endif
  146. admin-server_image_push: image_push_init
  147. docker tag admin-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-server:${RELEASE_VER}
  148. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-server:${RELEASE_VER}
  149. ifneq (${RELEASE_VER}, latest)
  150. ifeq (${NEED_LATEST}, TRUE)
  151. docker tag admin-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-server:latest
  152. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-server:latest
  153. endif
  154. endif
  155. openai-server_image_push: image_push_init
  156. docker tag openai-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-server:${RELEASE_VER}
  157. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-server:${RELEASE_VER}
  158. ifneq (${RELEASE_VER}, latest)
  159. ifeq (${NEED_LATEST}, TRUE)
  160. docker tag openai-server:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-server:latest
  161. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-server:latest
  162. endif
  163. endif
  164. taskset_image_push: pipeline_image_push vc-controller_image_push scheduler_image_push
  165. pipeline_image_push: image_push_init
  166. docker tag pipeline:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/pipeline:${RELEASE_VER}
  167. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/pipeline:${RELEASE_VER}
  168. ifneq (${RELEASE_VER}, latest)
  169. ifeq (${NEED_LATEST}, TRUE)
  170. docker tag pipeline:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/pipeline:latest
  171. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/pipeline:latest
  172. endif
  173. endif
  174. vc-controller_image_push: image_push_init
  175. docker tag vc-controller:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/vc-controller:${RELEASE_VER}
  176. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/vc-controller:${RELEASE_VER}
  177. ifneq (${RELEASE_VER}, latest)
  178. ifeq (${NEED_LATEST}, TRUE)
  179. docker tag vc-controller:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/vc-controller:latest
  180. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/vc-controller:latest
  181. endif
  182. endif
  183. scheduler_image_push: image_push_init
  184. docker tag scheduler:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/scheduler:${RELEASE_VER}
  185. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/scheduler:${RELEASE_VER}
  186. ifneq (${RELEASE_VER}, latest)
  187. ifeq (${NEED_LATEST}, TRUE)
  188. docker tag scheduler:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/scheduler:latest
  189. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/scheduler:latest
  190. endif
  191. endif
  192. admin-portal_image_push: image_push_init
  193. docker tag admin-portal:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-portal:${RELEASE_VER}
  194. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-portal:${RELEASE_VER}
  195. ifneq (${RELEASE_VER}, latest)
  196. ifeq (${NEED_LATEST}, TRUE)
  197. docker tag admin-portal:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-portal:latest
  198. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/admin-portal:latest
  199. endif
  200. endif
  201. openai-portal_image_push: image_push_init
  202. docker tag openai-portal:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-portal:${RELEASE_VER}
  203. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-portal:${RELEASE_VER}
  204. ifneq (${RELEASE_VER}, latest)
  205. ifeq (${NEED_LATEST}, TRUE)
  206. docker tag openai-portal:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-portal:latest
  207. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/openai-portal:latest
  208. endif
  209. endif
  210. api-doc_image_push: image_push_init
  211. docker tag api-doc:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:${RELEASE_VER}
  212. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:${RELEASE_VER}
  213. ifneq (${RELEASE_VER}, latest)
  214. ifeq (${NEED_LATEST}, TRUE)
  215. docker tag api-doc:${RELEASE_VER} ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:latest
  216. docker push ${DOCKER_HUB_HOST}/${DOCKER_HUB_PROJECT}/api-doc:latest
  217. endif
  218. endif
  219. # helm chart
  220. charts: charts_build charts_push
  221. charts_build:
  222. -mkdir -p ./tmp/charts
  223. helm package ./deploy/charts/octopus --version ${RELEASE_VER} --app-version ${RELEASE_VER} -d ./tmp/charts
  224. charts_push:
  225. -helm repo add --ca-file=${HARBOR_HUB_CA_FILE} --cert-file=${HARBOR_HUB_CERT_FILE} --username=${HARBOR_HUB_USERNAME} --password=${HARBOR_HUB_PASSWD} chartrepo ${HARBOR_HUB_HOST}/chartrepo/${HARBOR_HUB_PROJECT}
  226. helm push --ca-file=${HARBOR_HUB_CA_FILE} --cert-file=${HARBOR_HUB_CERT_FILE} --username=${HARBOR_HUB_USERNAME} --password=${HARBOR_HUB_PASSWD} ./tmp/charts/octopus-${RELEASE_VER}.tgz chartrepo
  227. ifeq (${DRONE_REPO}, OpenI/octopus)
  228. git clone ${CHARTS_GIT_CLONE} ${CHARTS_GIT_DIR}
  229. cp ./tmp/charts/octopus-${RELEASE_VER}.tgz ${CHARTS_GIT_DIR}
  230. helm repo index ${CHARTS_GIT_DIR} --url ${CHARTS_GIT_RAW}
  231. cd ${CHARTS_GIT_DIR} && git config --global user.email ${CHARTS_GIT_USER_EMAIL} && git config --global user.name ${CHARTS_GIT_USER_NAME} && git add index.yaml octopus-${RELEASE_VER}.tgz && git commit -m "${RELEASE_VER}" && git push
  232. endif

简介

面向多计算场景的一站式融合计算平台

https://octopus.openi.org.cn

CSS Go SVG Vue Markdown other