Docker中的Bcrypt安装失败 [英] Bcrypt installation fails in Docker

查看:509
本文介绍了Docker中的Bcrypt安装失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Docker中创建了一个使用MongoDB的Node应用程序。它工作正常,直到我包括 node.bcrypt.js 。这使得节点崩溃了 node-gyp bcrypt



应用程序在本地和Heroku上运行正常。



我尝试安装一些我在网上找到的建议包,这些软件是基于错误消息而被认为是需要的。这就是为什么我添加了一些额外的依赖关系,请参阅下面的dockerfile中的 node-gyp 相关的行。



现在,我找不到任何更多的建议,但它仍然无法工作。我觉得这是很奇怪的,它在本地和在Heorku,而不是在Docker上工作,因此这是我失踪的东西。



提前感谢。 >

错误:

 > crowdshelf-server@1.0.0 start / server 
>节点index.js

COPY发布/ bcrypt_lib.node
make:离开目录`/ server / node_modules / bcrypt / build'
module.js:338
throw呃;
^
错误:在Function.Module(module.js:336:15)
中找不到模块'./lib/topologies/server'
在module.require(module.js:365:17)
$($ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ <匿名> (/server/node_modules/mongodb/node_modules/mongodb-core/index.js:3:13)
在Module._compile(module.js:460:26)
在Object.Module._extensions。 .js(module.js:478:10)
在Module.load(module.js:355:32)
在Function.Module._load(module.js:310:12)
在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 / npmstart
npm ERR!节点v0.12.7
npm ERR! npm v2.11.3
npm ERR!代码ELIFECYCLE
npm ERR! crowdshelf-server@1.0.0开始:`node index.js`
npm ERR!退出状态1

这是在我添加了几个安装到我的Dockerfile之后,看到节点-GYP 。 Docker文件:

 #Ubuntu上的Base Docker映像
FROM ubuntu:最新

#安装mongodb
#install git,curl,python和mongo
#node-gyp
运行apt-get install -y build-essential make automake gcc g ++ cpp libkrb5-dev libc6-dev man- db autoconf pkg-config

#创建MongoDB数据目录
RUN mkdir -p / data / db

#mongodb setup
#安装NodeJS
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | sudo bash -
运行apt-get update&& apt-get install -y nodejs
运行npm install -g node-gyp

#Git-clone项目
#公开端口
#安装依赖关系并启动服务器数据库
CMD cd / server&& sh start.sh

starth.sh -script只需安装依赖关系并启动MongoDB和服务器。



编辑:
repo 告诉我查看 node-gyp依赖关系,但是我觉得这已经被上面显示的Dockerfile所覆盖了。

解决方案

我通过简单地更改 bcrypt -library来解决这个问题。 这个是基于类似的问题创建的,并提供了相同的API。与我问题中提到的图书馆的唯一区别是:

  bcrypt.hash(password,function(err,hash){
if(!err)callback(hash);
});

在此答案中链接的一个:



($)

$ b如果(!err)回调(hash);
});


I've created a Node-application with MongoDB that runs in Docker. It worked fine until I included node.bcrypt.js. This makes Node crash with node-gyp and bcrypt.

The app runs fine locally and on Heroku.

I tried to install a few suggested packages that I found online, that were known to be needed based on error messages. This is why I've added a few extra dependencies, see the node-gyp-related line in the dockerfile below.

Now it's gotten where I cannot find any more suggestions, but it still doens't work. I feel it's weird that it works both locally and on Heorku, but not on Docker, and therefore that it's something I'm missing.

Thanks in advance.

Error:

> 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

This is after I added a few installations to my Dockerfile, see the line after 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

The starth.sh-script simply installs dependencies and starts both MongoDB and server.

EDIT: The repo tells me to check out the node-gyp dependencies, but I feel that's been covered by the Dockerfile shown above.

解决方案

I solved this by simply changing the bcrypt-library. This one was created based on a similar problem, and provides the same API. The only difference from the library mentioned in my question is:

bcrypt.hash(password, function(err, hash) {
    if(!err) callback(hash);
});

While in the one linked in this answer:

bcrypt.hash(password, null, null, function(err, hash) { // Addd nulls
    if(!err) callback(hash);
});

这篇关于Docker中的Bcrypt安装失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆