不能npm在我的docker图像安装bcrypt
我试图让我的Sails.js
应用程序使用标准node
Docker镜像启动并运行,但是当它尝试npm install bcrypt
时,构build失败。
> bcrypt@0.8.0 install /myapp/node_modules/bcrypt > node-gyp rebuild gyp WARN install got an error, rolling back install gyp ERR! configure error gyp ERR! stack Error: node-v0.10.33.tar.gz local checksum 822ba41f2d77b704ab63e244dfef7431b31893c19bfe3bf228c06b6aff063ed5 not match remote 75dc26c33144e6d0dc91cb0d68aaf0570ed0a7e4b0c35f3a7a726b500edd081e gyp ERR! stack at deref (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:299:20) gyp ERR! stack at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/install.js:340:13) gyp ERR! stack at IncomingMessage.emit (events.js:117:20) gyp ERR! stack at _stream_readable.js:943:16 gyp ERR! stack at process._tickCallback (node.js:419:13) gyp ERR! System Linux 3.16.1-tinycore64 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /pos/node_modules/bcrypt gyp ERR! node -v v0.10.33 gyp ERR! node-gyp -v v1.0.2 gyp ERR! not ok
或者有时候它只是失败,如下所示:
> bcrypt@0.8.0 install /myapp/node_modules/bcrypt > node-gyp rebuild Killed
有时它只是无限期地停留在
> bcrypt@0.8.0 install /pos/node_modules/bcrypt > node-gyp rebuild
我的Dockerfile
看起来像:
FROM node:0.10.33 # copy the source files into the image ADD . /myapp # Define working directory. WORKDIR /myapp # Install node-gyp as global and ensure it's all clean and tide RUN npm install -g node-gyp && \ node-gyp clean && \ npm cache clean # Install project dependencies RUN npm install # Expose sails port (still in development mind you) EXPOSE 1337 # Define default command. CMD ["node app"]
我试过的东西
- 这个post在另一个Stackoverflow线程build议我也应该
RUN apt-get -y install g++
但添加到我的Dockerfile
没有区别,它只是报告,g++ is already the newest version.
- 这个postbuild议我确保安装
openssl
,所以我添加了RUN apt-get install -y openssl
,这也报告openssl is already the newest version
。 - 我也试过
RUN apt-get install -y build-essential
但也报告说它已经是最新版本了。
我已经看到了Node需要作为legacy
版本安装的build议,如果需要,我相信这是标准Node图像应该负责的事情,所以我也将这个问题报告为docker-library /节点项目。
同时,还有什么我应该尝试的?
感谢所有在评论和回答中给予build议的人引导我达成自己的结论。
这个问题要么是我的dvm
安装中的某种腐败,要么是dvm
和fig
之间的某种不兼容,但是我解决了这个问题,如下所示
dvm down brew remove fig brew remove dvm brew remove docker brew cleanup --force -s rm -rf ~/VirtualBox VMs/boot2docker-vm brew install docker brew install boot2docker boot2docker init boot2docker up echo export DOCKER_TLS_VERIFY=1 > ~/.bash_profile echo export DOCKER_CERT_PATH=~/.boot2docker/certs/boot2docker-vm > ~/.bash_profile echo export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 > ~/.bash_profile export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375 brew install fig fig build web
瞧 – 它的工作。
诀窍似乎是,我原来的boot2docker-vm
有一些相冲突的东西,原来是通过安装程序安装的,然后是homebrew
和boot2docker
与boot2docker
碰撞。 把它全部擦干净,重新开始,这一切都很好。