app-cloudep-tweeting-service/Makefile

71 lines
2.5 KiB
Makefile
Raw Normal View History

2024-08-28 04:19:47 +00:00
GO_CTL_NAME=goctl
# go-zero 生成風格
GO_ZERO_STYLE=go_zero
GO ?= go
GOFMT ?= gofmt "-s"
GOFILES := $(shell find . -name "*.go")
LDFLAGS := -s -w
VERSION="v1.0.1"
DOCKER_REPO="igs170911/feed"
.PHONY: test
test: # 進行測試
go test -v --cover ./...
.PHONY: fmt
fmt: # 格式優化
$(GOFMT) -w $(GOFILES)
goimports -w ./
2024-09-03 09:47:34 +00:00
golangci-lint run
2024-08-28 04:19:47 +00:00
.PHONY: gen-rpc
gen-rpc: # 建立 rpc code
2024-08-28 14:24:47 +00:00
$(GO_CTL_NAME) rpc protoc ./generate/protobuf/tweeting.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
2024-08-28 04:19:47 +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 feed.go
@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)" .
rm -rf Dockerfile
@echo "Generate core-api files successfully"
2024-08-28 09:09:01 +00:00
gen-mongo-model: # 建立 rpc 資料庫
# 只產生 Model 剩下的要自己撰寫,連欄位名稱也是
goctl model mongo -t post --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
goctl model mongo -t comment --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
2024-09-01 13:49:28 +00:00
goctl model mongo -t tags --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
goctl model mongo -t post_likes --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
goctl model mongo -t comment_likes --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
@echo "Generate mongo model files successfully"
.PHONY: mock-gen
mock-gen: # 建立 mock 資料
mockgen -source=./internal/model/mongo/post_model_gen.go -destination=./internal/mock/model/post_model_gen.go -package=mock
mockgen -source=./internal/model/mongo/post_model.go -destination=./internal/mock/model/post_model.go -package=mock
mockgen -source=./internal/model/mongo/comment_model_gen.go -destination=./internal/mock/model/comment_model_gen.go -package=mock
mockgen -source=./internal/model/mongo/comment_model.go -destination=./internal/mock/model/comment_model.go -package=mock
@echo "Generate mock files successfully"
.PHONY: migrate-database
migrate-database:
migrate -source file://generate/database/migrations/mongodb -database 'mongodb://127.0.0.1:27017/digimon_tweeting' up