2024-08-20 06:35:14 +00:00
|
|
|
GO_CTL_NAME=goctl
|
2024-08-20 06:35:46 +00:00
|
|
|
|
2024-08-20 06:35:14 +00:00
|
|
|
# go-zero 生成風格
|
|
|
|
GO_ZERO_STYLE=go_zero
|
|
|
|
|
|
|
|
GO ?= go
|
|
|
|
GOFMT ?= gofmt "-s"
|
|
|
|
GOFILES := $(shell find . -name "*.go")
|
|
|
|
LDFLAGS := -s -w
|
2024-08-20 10:05:39 +00:00
|
|
|
VERSION="v1.0.3"
|
|
|
|
DOCKER_REPO="igs170911/notification"
|
|
|
|
|
2024-08-20 06:35:14 +00:00
|
|
|
.PHONY: test
|
|
|
|
test: # 進行測試
|
|
|
|
go test -v --cover ./...
|
|
|
|
|
|
|
|
.PHONY: fmt
|
|
|
|
fmt: # 格式優化
|
|
|
|
$(GOFMT) -w $(GOFILES)
|
|
|
|
goimports -w ./
|
|
|
|
|
|
|
|
.PHONY: gen-rpc
|
|
|
|
gen-rpc: # 建立 rpc code
|
2024-08-26 08:34:16 +00:00
|
|
|
$(GO_CTL_NAME) rpc protoc ./generate/protobuf/notification.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
|
2024-10-28 08:43:16 +00:00
|
|
|
cp ./etc/service.example.yaml ./etc/notification.yaml
|
2024-08-20 06:35:14 +00:00
|
|
|
go mod tidy
|
|
|
|
@echo "Generate core-api files successfully"
|
|
|
|
|
|
|
|
.PHONY: gen-clean
|
|
|
|
gen-clean: # 建立 rpc code
|
|
|
|
rm -rf ./client
|
|
|
|
rm -rf ./etc
|
|
|
|
rm -rf ./gen_result
|
|
|
|
rm -rf ./internal
|
|
|
|
rm -rf go.mod
|
|
|
|
rm -rf go.sum
|
|
|
|
rm -rf service.go
|
2024-08-20 10:05:39 +00:00
|
|
|
@echo "Generate core-api files successfully"
|
|
|
|
|
|
|
|
.PHONY: run-docker
|
|
|
|
run-docker: # 建立 rpc code
|
|
|
|
docker run --platform=linux/arm64/v8 -p 8080:8080 $(DOCKER_REPO):$(VERSION)
|
|
|
|
|
|
|
|
.PHONY: build-docker
|
|
|
|
build-docker:
|
|
|
|
cp ./build/Dockerfile Dockerfile
|
|
|
|
docker buildx build -t $(DOCKER_REPO):$(VERSION) --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/ed_25519)" .
|
2024-08-20 10:17:34 +00:00
|
|
|
rm -rf Dockerfile
|
|
|
|
@echo "Generate core-api files successfully"
|