Files
novatask/Makefile
lianghuanjie b098e50eb0 email reward
2025-01-03 20:44:03 +08:00

64 lines
1.7 KiB
Makefile

host ?= 192.168.20.101: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.json" -api doc/api/nova.api -dir doc/swagger
.PHONY: api
# 根据api文件生成代码
api:
make api-format
goctl api go -api doc/api/nova.api --dir . --style go_zero
.PHONY: build
# 编译二进制可执行文件
build:
mkdir -p bin/ && CGO_ENABLED=0 go build -ldflags="-s -w" -tags no_k8s -o ./bin/ ./...
.PHONY: img
# 构建Docker镜像
img:
docker build --platform=amd64 -t 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