Makefile 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. PROJECT:=config-center-server
  2. .PHONY: build
  3. VERSION_FILE:=./VERSION
  4. VERSION = $(shell cat ${VERSION_FILE})
  5. GO_LIB_VERSION = $(shell grep 'git.cestong.com.cn/cecf/cecf-golib v' go.mod | cut -d' ' -f2)
  6. HX_VERSION = $(shell grep 'git.cestong.com.cn/cecf/config-center-server v' go.mod | cut -d' ' -f2)
  7. BIN_PATH=./bin/config-center-server
  8. updateGoLibVersion:
  9. sed -i.bak "s/goLibVersion\s*=\s*\".*\"/goLibVersion=\"${GO_LIB_VERSION}\"/g" ./version.go
  10. rm -f ./version.go.bak
  11. updateVersion:
  12. sed -i.bak "s/version\s*=\s*\".*\"/version=\"${VERSION}\"/g" ./version.go
  13. rm -f ./version.go.bak
  14. updateVersions: updateGoLibVersion updateVersion
  15. echo ${VERSION}
  16. build: updateVersions
  17. go mod tidy
  18. CGO_ENABLED=0 go build -o ${BIN_PATH}
  19. build-prod: updateVersion updateGoLibVersion
  20. go mod tidy
  21. CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o ${BIN_PATH}
  22. run-cest-2: build
  23. ssh cest-2 'cd config-center-server && ./stop.sh'
  24. scp bin/config-center-server cest-2:~/config-center-server/bin/
  25. ssh cest-2 'cd config-center-server && ./start.sh'
  26. run: build
  27. ${BIN_PATH} server -c config/settings.yml
  28. db-dump:
  29. mysqldump -u root -h 127.0.0.1 -p hx > db-bak.sql
  30. DOCKER_IMAGE_NAME=config-center-server
  31. DOCKER_REMOTE_IMAGE_NAME=registry.cestong.com:8150/cecf/${DOCKER_IMAGE_NAME}
  32. docker-build:
  33. docker build . -f Dockerfile -t ${DOCKER_IMAGE_NAME}
  34. docker-push: docker-build
  35. docker tag ${DOCKER_IMAGE_NAME} ${DOCKER_REMOTE_IMAGE_NAME}
  36. docker push ${DOCKER_REMOTE_IMAGE_NAME}
  37. deploy-test: docker-push
  38. ssh cest-2 'cd hx-admin-server && docker-compose pull && docker-compose up -d'
  39. release-tag:
  40. git tag "v${VERSION}"
  41. git push --tags