feat: 完成后端全套自动化脚本、Makefile、README,支持一键启动与测试
This commit is contained in:
25
backend/scripts/gen-proto.sh
Executable file
25
backend/scripts/gen-proto.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 生成 proto 代码的脚本
|
||||
|
||||
# 定义颜色
|
||||
GREEN="\033[0;32m"
|
||||
YELLOW="\033[1;33m"
|
||||
RED="\033[0;31m"
|
||||
NC="\033[0m" # No Color
|
||||
|
||||
echo -e "${GREEN}Starting proto compilation...${NC}"
|
||||
|
||||
# 使用 Docker 运行 protoc 编译
|
||||
if docker run --rm -v "$(pwd):/app" -w /app golang:1.26.1-alpine3.23 sh -c "\
|
||||
apk add --no-cache protobuf-dev && \
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && \
|
||||
protoc --go_out=. --go-grpc_out=. services/user-svc/user.proto && \
|
||||
protoc --go_out=. --go-grpc_out=. shared/proto/common.proto\
|
||||
"; then
|
||||
echo -e "${GREEN}Proto compilation completed successfully!${NC}"
|
||||
else
|
||||
echo -e "${RED}Proto compilation failed!${NC}"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user