我的节点Dockfile:
Dockfile
# Set the base image to ubuntu FROM ubuntu # Define working directory ADD . /src WORKDIR /src # Install Node.js & other dependencies RUN apt-get update && \ apt-get -y install curl && \ apt-get -y install sudo && \ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash - && \ apt-get -y install python build-essential nodejs RUN npm install -g node-gyp && \ node-gyp clean && \ npm cache clean RUN node -v # Install nodemon RUN npm install -g nodemon ADD package.json /src/package.json RUN cd /src && npm install # Expose port EXPOSE 8080 # Run app using nodemon CMD npm install; nodemon /src/app.js
这是我的docker-compose.yml:
docker-compose.yml
nginx: build: ./nginx links: - node1:node1 - node2:node2 - node3:node3 ports: - "80:80" redis: image: redis ports: - "6379" node1: build: ./node links: - redis ports: - "8080" node2: build: ./node links: - redis ports: - "8080" node3: build: ./node links: - redis ports: - "8080"
docker-compose build运行成功并且Redis / Nginx安装正确,docker-compose up但是节点实例抛出此错误:
docker-compose build
docker-compose up
node2_1 | /src/node_modules/bcrypt/node_modules/bindings/bindings.js:83 node2_1 | throw e node2_1 | ^ node2_1 | Error: /src/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header node2_1 | at Error (native) node2_1 | at Module.load (module.js:355:32) node2_1 | at Function.Module._load (module.js:310:12) node2_1 | at Module.require (module.js:365:17) node2_1 | at require (module.js:384:17) node2_1 | at bindings (/src/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44) node2_1 | at Object.<anonymous> (/src/node_modules/bcrypt/bcrypt.js:3:35) node2_1 | at Module._compile (module.js:460:26) node2_1 | at Object.Module._extensions..js (module.js:478:10) node2_1 | at Module.load (module.js:355:32) node2_1 | at Function.Module._load (module.js:310:12) node2_1 | at Module.require (module.js:365:17) node2_1 | at require (module.js:384:17) node2_1 | at Object.<anonymous> (/src/api/models/User.js:10:14) node2_1 | at Module._compile (module.js:460:26) node2_1 | at Object.Module._extensions..js (module.js:478:10) node2_1 | 19 Aug 20:21:11 - [nodemon] app crashed - waiting for file changes before starting...
我到处搜索,似乎找不到有效的解决方案。我尝试使用常规设置url:,https://deb.nodesource.com/setup特别是install python2.7和使用ubuntu:15.04图像。
https://deb.nodesource.com/setup
python2.7
ubuntu:15.04
我已经读到,当人们尝试在OS X(我的OS)上构建了Linux env之后使用bcrypt时,会发生这种情况,但是我认为这不是问题,因为我正在使用docker和boot2docker。
在我的程序包配置中"bcrypt":"^0.8.0",当我取出^并将其更改为"bcrypt":"0.8.0"我时,它能够使一切正常运行。
"bcrypt":"^0.8.0"
^
"bcrypt":"0.8.0"
问题是它试图运行bcrypt 0.8.5,并且由于某种原因导致了问题。