diff --git a/Dockerfile b/Dockerfile index 71433d0..d422cad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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