26 lines
780 B
Bash
Executable File
26 lines
780 B
Bash
Executable File
#!/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
|