简体   繁体   English

如何在 docker 容器中使用 nestjs 运行 gRPC 微服务

[英]How to run gRPC microservice with nestjs in a docker container

I'm setting up a Nest JS microservice with gRPC in a docker container.我正在 docker 容器中使用 gRPC 设置 Nest JS 微服务。 I have installed the grpc package from npm but when i start the container i get an error message that the "grpc package is missing" how do i make the package available in the container我已经从 npm 安装了 grpc 包,但是当我启动容器时,我收到一条错误消息,提示“grpc 包丢失”,我该如何使该包在容器中可用

I have tried to install the grpc package with the RUN command in the dockerfile but i keep getting the same error.我试图在 dockerfile 中使用 RUN 命令安装 grpc 包,但我一直收到同样的错误。

FROM node:10.15.3

WORKDIR /usr/src/app/auth

COPY package*.json ./
RUN npm install
RUN npm install --save grpc

COPY . .

EXPOSE 3001

it works normally outside the container, but for some reason its not working when i run it in a container它在容器外正常工作,但由于某种原因,当我在容器中运行它时它不起作用

What worked for me was adding the对我有用的是添加

RUN npm rebuild grpc --force

after the npm install在 npm 安装之后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM