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

74 lines
1.9 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. include ./hack/hack-cli.mk
  2. # Update GoFrame and its CLI to latest stable version.
  3. .PHONY: up
  4. up: cli.install
  5. @gf up -a
  6. # Build binary using configuration from hack/config.yaml.
  7. .PHONY: build
  8. build: cli.install
  9. @gf build -ew
  10. # Parse api and generate controller/sdk.
  11. .PHONY: ctrl
  12. ctrl: cli.install
  13. @gf gen ctrl --srcFolder './app/api' --dstFolder './app/controller'
  14. # Generate Go files for DAO/DO/Entity.
  15. .PHONY: dao
  16. dao: cli.install
  17. @gf gen dao
  18. # Parse current project go files and generate enums go file.
  19. .PHONY: enums
  20. enums: cli.install
  21. @gf gen enums
  22. # Generate Go files for Service.
  23. .PHONY: service
  24. service: cli.install
  25. @gf gen service --srcFolder './app/logic' --dstFolder './app/service'
  26. # Build docker image.
  27. .PHONY: image
  28. image: cli.install
  29. $(eval _TAG = $(shell git describe --dirty --always --tags --abbrev=8 --match 'v*' | sed 's/-/./2' | sed 's/-/./2'))
  30. ifneq (, $(shell git status --porcelain 2>/dev/null))
  31. $(eval _TAG = $(_TAG).dirty)
  32. endif
  33. $(eval _TAG = $(if ${TAG}, ${TAG}, $(_TAG)))
  34. $(eval _PUSH = $(if ${PUSH}, ${PUSH}, ))
  35. @gf docker ${_PUSH} -tn $(DOCKER_NAME):${_TAG};
  36. # Build docker image and automatically push to docker repo.
  37. .PHONY: image.push
  38. image.push:
  39. @make image PUSH=-p;
  40. # Deploy image and yaml to current kubectl environment.
  41. .PHONY: deploy
  42. deploy:
  43. $(eval _TAG = $(if ${TAG}, ${TAG}, develop))
  44. @set -e; \
  45. mkdir -p $(ROOT_DIR)/temp/kustomize;\
  46. cd $(ROOT_DIR)/manifest/deploy/kustomize/overlays/${_ENV};\
  47. kustomize build > $(ROOT_DIR)/temp/kustomize.yaml;\
  48. kubectl apply -f $(ROOT_DIR)/temp/kustomize.yaml; \
  49. if [ $(DEPLOY_NAME) != "" ]; then \
  50. kubectl patch -n $(NAMESPACE) deployment/$(DEPLOY_NAME) -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"$(shell date +%s)\"}}}}}"; \
  51. fi;
  52. # Parsing protobuf files and generating go files.
  53. .PHONY: pb
  54. pb: cli.install
  55. @gf gen pb
  56. # Generate protobuf files for database tables.
  57. .PHONY: pbentity
  58. pbentity: cli.install
  59. @gf gen pbentity