chore(docker): 优化 Dockerfile 中的 proto 文件生成步骤

- 修改 proto 文件生成命令,确保只生成所需的 go、grpc、validate 和 errors 文件,排除 HTTP 相关文件以避免依赖问题。
- 通过指定路径和文件类型,提升生成效率并减少不必要的构建依赖。
This commit is contained in:
zhouyonggao 2025-12-20 15:21:24 +08:00
parent 122f7deb5d
commit 7b6c4f2cf2
1 changed files with 9 additions and 2 deletions

View File

@ -33,9 +33,16 @@ RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
WORKDIR /app
COPY grpc/ ./grpc/
# 在容器内生成 proto 文件
# 在容器内生成 proto 文件(只生成需要的文件,排除 HTTP 相关)
WORKDIR /app/grpc
RUN make generate
# 只生成 go、grpc、validate 和 errors 文件,不生成 http 文件(避免依赖问题)
RUN protoc --proto_path=./ \
--proto_path=./third_party \
--go_out=paths=source_relative:./ \
--go-grpc_out=paths=source_relative:./ \
--validate_out=paths=source_relative,lang=go:./ \
--go-errors_out=paths=source_relative:./ \
$(find . -path "./third_party" -prune -o -type f -name "*.proto" -print)
# 生成 proto 后更新依赖proto 生成的文件可能需要额外的依赖)
WORKDIR /app/grpc/user/userv1