初始化项目
This commit is contained in:
65
Makefile
Normal file
65
Makefile
Normal file
@@ -0,0 +1,65 @@
|
||||
host ?= 192.168.2.108:3306
|
||||
user ?= huangjie
|
||||
pwd ?= jMDqPQM^a6hsAR
|
||||
table ?=
|
||||
cache ?=
|
||||
database ?= "nova_home"
|
||||
|
||||
.PHONY: db
|
||||
# 链接数据库生成模型代码
|
||||
db:
|
||||
goctl model mysql datasource -url="${user}:${pwd}@tcp(${host})/${database}" -table="${table}" --dir internal/model --strict --style go_zero ${cache}
|
||||
|
||||
.PHONY: init
|
||||
# 初始化开发环境,安装依赖工具
|
||||
init:
|
||||
go install github.com/zeromicro/go-zero/tools/goctl@latest
|
||||
goctl env check --install --verbose --force
|
||||
go install github.com/zeromicro/goctl-swagger@latest
|
||||
|
||||
.PHONY: api-format
|
||||
# 格式化api文件
|
||||
api-format:
|
||||
goctl api format --dir doc/api/
|
||||
goctl api plugin -plugin goctl-swagger="swagger -filename nova-task.json" -api doc/api/nova-task.api -dir doc/swagger
|
||||
|
||||
.PHONY: api
|
||||
# 根据api文件生成代码
|
||||
api:
|
||||
make api-format
|
||||
goctl api go -api doc/api/nova-task.api --dir . --style go_zero
|
||||
|
||||
.PHONY: build
|
||||
# 编译二进制可执行文件
|
||||
build:
|
||||
mkdir -p bin/ && go build -ldflags="-s -w" -o ./bin/ ./...
|
||||
|
||||
.PHONY: img
|
||||
# 构建Docker镜像
|
||||
img:
|
||||
docker build --platform=amd64 -t nova-task:latest .
|
||||
docker tag `docker images -aq -f "reference=nova-task:latest"` harbor.phantom-u3d002.com/nova/nova-task:latest
|
||||
|
||||
.PHONY: push
|
||||
push:
|
||||
docker push harbor.phantom-u3d002.com/nova/nova-task:latest
|
||||
|
||||
|
||||
# 帮助信息
|
||||
help:
|
||||
@echo ''
|
||||
@echo 'Usage:'
|
||||
@echo ' make [target]'
|
||||
@echo ''
|
||||
@echo 'Targets:'
|
||||
@awk '/^[a-zA-Z\-\0-9]+:/ { \
|
||||
helpMessage = match(lastLine, /^# (.*)/); \
|
||||
if (helpMessage) { \
|
||||
helpCommand = substr($$1, 0, index($$1, ":")-1); \
|
||||
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
|
||||
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
|
||||
} \
|
||||
} \
|
||||
{ lastLine = $$0 }' $(MAKEFILE_LIST)
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
Reference in New Issue
Block a user