【发布时间】:2017-02-02 19:20:57
【问题描述】:
我已经使用 MongoDB 创建了一个在 Docker 中运行的节点应用程序。在我包含node.bcrypt.js 之前它运行良好。这会导致 Node 在 node-gyp 和 bcrypt 崩溃。
该应用在本地和 Heroku 上运行良好。
我尝试安装一些我在网上找到的建议软件包,根据错误消息已知它们是必需的。这就是为什么我添加了一些额外的依赖项,请参阅下面 dockerfile 中的node-gyp-related 行。
现在它已经到了我找不到更多建议的地方,但它仍然不起作用。我觉得它在本地和 Heorku 上都有效,但在 Docker 上无效,这很奇怪,因此我缺少它。
提前致谢。
错误:
> crowdshelf-server@1.0.0 start /server
> node index.js
COPY Release/bcrypt_lib.node
make: Leaving directory `/server/node_modules/bcrypt/build'
module.js:338
throw err;
^
Error: Cannot find module './lib/topologies/server'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/server/node_modules/mongodb/node_modules/mongodb-core/index.js:3:13)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
npm ERR! Linux 3.13.0-58-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "start"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! crowdshelf-server@1.0.0 start: `node index.js`
npm ERR! Exit status 1
这是在我向 Dockerfile 添加了一些安装之后,请参阅node-gyp 之后的行。 Dockerfile:
# Base Docker-image on Ubuntu
FROM ubuntu:latest
#install mongodb
#install git, curl, python and mongo
# node-gyp
RUN apt-get install -y build-essential make automake gcc g++ cpp libkrb5-dev libc6-dev man-db autoconf pkg-config
# Create the MongoDB data directory
RUN mkdir -p /data/db
# mongodb setup
# Install NodeJS
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
RUN apt-get update && apt-get install -y nodejs
RUN npm install -g node-gyp
# Git-clone project
# expose ports
# Install dependencies and start server and database
CMD cd /server && sh start.sh
starth.sh-脚本只是安装依赖项并启动 MongoDB 和服务器。
编辑: repo 告诉我查看node-gyp dependencies,但我觉得上面显示的 Dockerfile 已经涵盖了这一点。
【问题讨论】: