Makefile 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. BIN_OUTPUT_PATH=./bin
  2. SERVER_NAME=hx-app-server
  3. BUILD_BIN_OUTPUT_PATH=${BIN_OUTPUT_PATH}/${SERVER_NAME}
  4. VERSION_FILE:=./VERSION
  5. VERSION = $(shell cat ${VERSION_FILE})
  6. GO_LIB_VERSION = $(shell grep 'git.cestong.com.cn/cecf/cecf-golib v' go.mod | cut -d' ' -f2)
  7. updateGoLibVersion:
  8. sed -i.bak "s/goLibVersion\s*=\s*\".*\"/goLibVersion=\"${GO_LIB_VERSION}\"/g" cmd/server/version.go
  9. rm -f cmd/server/version.go.bak
  10. updateVersion:
  11. sed -i.bak "s/version\s*=\s*\".*\"/version=\"${VERSION}\"/g" cmd/server/version.go
  12. rm -f cmd/server/version.go.bak
  13. updateVersions:updateGoLibVersion updateVersion
  14. echo ${VERSION}
  15. build-dev: updateVersions
  16. go mod tidy
  17. go build -o ${BUILD_BIN_OUTPUT_PATH} git.cestong.com.cn/cecf/hx-mobile-server-api/cmd/server
  18. build-prod: updateVersions
  19. go mod tidy
  20. CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o bin/hx-app-server git.cestong.com.cn/cecf/hx-mobile-server-api/cmd/server
  21. run-dev: build-dev
  22. ${BUILD_BIN_OUTPUT_PATH} -c conf/config.yml
  23. doc-gen:
  24. swag init -d cmd/server/
  25. doc-serve: doc-gen
  26. swagger serve --host 0.0.0.0 --port 6209 --no-open docs/swagger.json
  27. CLI_GEN_DIR=./client
  28. JS_CLI_DIR=${CLI_GEN_DIR}/js
  29. GO_CLI_DIR=${CLI_GEN_DIR}/go-client
  30. js-client-clean:
  31. rm -rf ${JS_CLI_DIR}
  32. js-client-gen: doc-gen js-client-clean
  33. java -jar ~/install/swagger-codegen-cli.jar generate -i docs/swagger.yaml -l javascript -o ${JS_CLI_DIR}
  34. go-client-clean:
  35. rm -rf ${GO_CLI_DIR}
  36. go-client-gen: doc-gen go-client-clean
  37. java -jar ~/install/swagger-codegen-cli.jar generate -i docs/swagger.yaml -l go -o ${GO_CLI_DIR}
  38. test-api:
  39. go test -v ./test/api
  40. DOCKER_IMAGE_NAME=observe-front
  41. DOCKER_REMOTE_IMAGE_NAME=reg.cestong.com.cn/cecf/${DOCKER_IMAGE_NAME}
  42. #DOCKER_REMOTE_IMAGE_NAME=pujielan/${DOCKER_IMAGE_NAME}
  43. docker-build:
  44. npm run build:prod
  45. git rev-parse --short HEAD > dist/version
  46. docker build . -t ${DOCKER_IMAGE_NAME}
  47. docker-push: docker-build
  48. docker tag ${DOCKER_IMAGE_NAME} ${DOCKER_REMOTE_IMAGE_NAME}
  49. docker push ${DOCKER_REMOTE_IMAGE_NAME}
  50. deploy: docker-push
  51. ssh km1 'kubectl rollout restart deployment obf -n observe'
  52. deploy-test: docker-push
  53. ssh cest-2 'cd hx-app-server && docker-compose pull && docker-compose up -d'
  54. docker-build-php:
  55. docker build -t registry.cestong.com:8150/zhixueyun/hx-php-server -f ./deploy/php/Dockerfile .
  56. docker-push-php: docker-build-php
  57. docker push registry.cestong.com:8150/zhixueyun/hx-php-server
  58. docker-build-nginx:
  59. docker build -t registry.cestong.com:8150/zhixueyun/hx-nginx -f ./deploy/nginx/Dockerfile .
  60. db-backup-file = ~/data/test_ctc_backup_$(shell date '+%Y-%m-%dT%H-%M').sql
  61. db-backup-test:
  62. ssh cest-2 'cd data && mysqldump -h 172.17.172.137 -u root -p1qaz2wsx3edc -P 53306 --databases ctc > dump.sql'
  63. scp cest-2:~/data/dump.sql ${db-backup-file}
  64. db-sync-to-local: db-backup-test
  65. mysql -u root -p1234 -h 127.0.0.1 < ${db-backup-file}
  66. release-tag:
  67. git tag "v${VERSION}"
  68. git push --tags