亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用多個 Proto 構建 Docker - 未找到 Proto 文件

使用多個 Proto 構建 Docker - 未找到 Proto 文件

Go
慕田峪7331174 2023-03-15 14:34:17
我遇到了無法構建包含多個原型文件(服務器和文本)的 Dockerfile 的問題。服務器原型在 Dockerfile 目錄中,但文本原型在 Dockerfile 父目錄中。所以我在父目錄中構建 Dockerfile 以將文本原型復制到 Docker 構建中。proto/text.proto: File not found.即使我將 復制proto/text.proto到確切位置,Docker 構建仍會抱怨server/proto/server.proto.這是我的所有文件:Docker文件FROM --platform=linux/x86_64 golang:1.19.3-bullseye# Install grpcRUN go install google.golang.org/grpc/cmd/[email protected] && \    go install google.golang.org/protobuf/cmd/[email protected] /appCOPY server/. /appCOPY proto/text.proto /app/proto/text.proto# Install protoc and zip system libraryRUN apt-get update && apt-get install -y zip && \    mkdir /opt/protoc && cd /opt/protoc && wget https://github.com/protocolbuffers/protobuf/releases/download/v3.7.0/protoc-3.7.0-linux-x86_64.zip && \    unzip protoc-3.7.0-linux-x86_64.zip# Copy the grpc proto file and generate the go moduleRUN /opt/protoc/bin/protoc --go_out=/app/proto --proto_path=/app/proto --go_opt=paths=source_relative --go-grpc_out=/app/proto --go-grpc_opt=paths=source_relative /app/proto/text.proto /app/proto/server.protoEXPOSE 5051RUN go build -o /serverENTRYPOINT ["/server"]目錄樹1.text    ├── admin    │   ├── Dockerfile    │   ├── app.js    │   ├── package.json    │   └── web    │       ├── html    │       │   └── index.html    │       └── resources    ├── compose.yaml    ├── db    │   ├── Dockerfile    │   ├── main.go    │   ├── proto    │   │   ├── db.pb.go    │   │   ├── db.proto    │   │   └── db_grpc.pb.go    │   └── text.db    ├── go.mod    ├── go.sum    ├── proto    │   ├── text.pb.go    │   └── text.proto    └── server        ├── Dockerfile        ├── main.go        ├── proto        │   ├── server.pb.go        │   ├── server.proto        │   └── server_grpc.pb.go        └── text            ├── text.go            └── text_test.go我能夠在根text目錄中運行以下協議:protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/text.proto db/proto/db.proto server/proto/server.proto并在本地運行服務器,但我無法構建我的 Docker:
查看完整描述

1 回答

?
浮云間

TA貢獻1829條經驗 獲得超4個贊

根據評論;在您的 docker 映像中,您具有以下目錄結構:

/app/proto/server.proto 
/app/proto/text.proto

server.proto進口text.protoimport "proto/text.proto".

這意味著protoc將查找proto/text.proto在導入路徑中調用的文件。您指定為meaning--proto_path=/app/proto的參數,它將檢查不存在的內容(因此出現問題)。要解決此問題,請刪除(因此使用工作文件夾)或指定.protocprotoc/app/proto/proto/text.proto--proto_path=/app/protoprotoc--proto_path=/app


查看完整回答
反對 回復 2023-03-15
  • 1 回答
  • 0 關注
  • 146 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號