尝试使用以下Dockerfile和依赖项构建应用的Docker映像
FROM alpine
WORKDIR /usr/src/app
ARG PORT=3000
ENV PORT=$PORT
COPY package*.json ./
RUN apk add --no-cache nodejs npm
RUN npm install
COPY . .
EXPOSE $PORT
CMD [ "node", "server.js" ]
"dependencies":
"express": "^4.17.1",
"minimist": "1.2.0",
"socket.io": "^2.3.0",
"kurento-client": "^6.9.0"
这将导致以下错误:
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/KurentoForks/reconnect-ws.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
如果排除最后一个依赖项,则图像构建有效。 NODE v12.18.4
,NPM 6.14.6
已安装。
应用在本地正常运行。非常感谢您的帮助。
答案 0 :(得分:0)
对上述dockerfile进行以下更改后工作: 运行apk添加--update nodejs nodejs-npm运行apk添加git运行apk添加python2 并更改 “ kurento-client”:“ ^ 6.15.0”
kurento-client v6.9.0使事情变得复杂,因为它需要先通过nvm安装来安装节点v8.17,然后再添加git和python