Makefile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. PROJECT:=go-admin
  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/hx-mobile-server-api v' go.mod | cut -d' ' -f2)
  7. updateGoLibVersion:
  8. sed -i.bak "s/goLibVersion\s*=\s*\".*\"/goLibVersion=\"${GO_LIB_VERSION}\"/g" ./version.go
  9. rm -f ./version.go.bak
  10. updateHXLibVersion:
  11. sed -i.bak "s/hxVersion\s*=\s*\".*\"/hxVersion=\"${HX_VERSION}\"/g" ./version.go
  12. rm -f ./version.go.bak
  13. updateVersion:
  14. sed -i.bak "s/version\s*=\s*\".*\"/version=\"${VERSION}\"/g" ./version.go
  15. rm -f ./version.go.bak
  16. updateVersions: updateGoLibVersion updateHXLibVersion updateVersion
  17. echo ${VERSION}
  18. build: updateVersions
  19. go mod tidy
  20. CGO_ENABLED=0 go build -o bin/hx-admin-server .
  21. build-prod: updateVersion updateGoLibVersion updateHXLibVersion
  22. go mod tidy
  23. CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -a -installsuffix cgo -o bin/hx-admin-server .
  24. run: build
  25. ./bin/hx-admin-server server -c config/settings.yml
  26. v0-update:
  27. cp -rf backend-v0/app/* /home/yawyd/containers/hx-v0/container/html/ctc/app/
  28. sudo chown -R www-data:www-data /home/yawyd/containers/hx-v0/container/html/ctc/app/
  29. docker restart ctc-php
  30. db-dump:
  31. mysqldump -u root -h 127.0.0.1 -p hx > db-bak.sql
  32. DOCKER_IMAGE_NAME=hx-admin-server
  33. DOCKER_REMOTE_IMAGE_NAME=registry.cestong.com:8150/zhixueyun/${DOCKER_IMAGE_NAME}
  34. docker-build:
  35. docker build . -f Dockerfile -t ${DOCKER_IMAGE_NAME}
  36. docker-push: docker-build
  37. docker tag ${DOCKER_IMAGE_NAME} ${DOCKER_REMOTE_IMAGE_NAME}
  38. docker push ${DOCKER_REMOTE_IMAGE_NAME}
  39. deploy-test: docker-push
  40. ssh cest-2 'cd hx-admin-server && docker-compose pull && docker-compose up -d'
  41. release-tag:
  42. git tag "v${VERSION}"
  43. git push --tags