bcrypt安装不上_Docker中的Bcrypt安装失败

bd96500e110b49cbb3cd949968f18be7.png

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. (/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 中 OpenWebUI 的管理员密码 对于忘记 Docker 容器内运行的 OpenWebUI 管理员密码的情况,可以采取以下措施来恢复访问权限。 #### 方法一:通过修改配置文件重置密码 如果容器允许挂载外部卷用于保存配置数据,则可以直接编辑这些配置文件。通常情况下,用户名和加密后的密码会存储在一个 JSON 文件或其他类型的配置文件中。停止目标容器并定位到对应的主机目录下查找相关设置[^1]: ```bash docker stop openwebui_container_name nano /path/to/config.json ``` 找到 `admin` 用户条目下的 `passwordHash` 字段,并将其替换为已知的新哈希值(可以通过在线工具生成)。完成后重启服务使更改生效。 #### 方法二:直接操作数据库内的记录 当应用程序依赖于内部 SQLite 数据库管理账户信息时,可按照如下步骤执行命令行指令完成密码更新工作[^2]: 1. 进入正在运行的服务实例内部环境; ```bash docker exec -it openwebui_container bash ``` 2. 使用 sqlite3 工具连接至本地的数据仓库; ```sql sqlite3 /app/data/database.sqlite ``` 3. 执行 SQL 语句变更指定用户的认证凭证: ```sql UPDATE users SET password='$2b$10$92IXUNpkjO0rOQ5byMi.Ye4oKdHlJcV7k8FmXfL6q3oz3RcAJNylP' WHERE username='admin'; ``` 请注意上述 `$2b...` 部分代表 bcrypt 加密算法产生的散列字符串形式的新密码 "secret" ,实际应用过程中应当替换成自己设定的安全强度更高的选项。 最后记得退出交互模式并重新启动受影响的服务进程以便让最新的改动立即起作用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值