Bcrypt:与Docker和Sails.JS无效的ELF头 [英] Bcrypt: invalid ELF header with Docker and Sails.JS

查看:196
本文介绍了Bcrypt:与Docker和Sails.JS无效的ELF头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的节点 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

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 runs successfully and Redis/Nginx setup correcly on docker-compose up but the node instances throw this error:

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...

我已经搜索过,似乎找不到有效的解决方案。我已经尝试使用常规安装网址: https://deb.nodesource.com/setup ,具体安装 python2.7 ,并使用 ubuntu:15.04 图像。

I've searched all over and can't seem to find a solution that works. I've tried using the regular setup url: https://deb.nodesource.com/setup, specifically installing python2.7, and using the ubuntu:15.04 image.

我已经看到,当人们尝试在OS X(我的操作系统)上构建一个linux环境之后使用bcrypt,但是,由于我正在使用docker和boot2docker构建所有内容,我认为不会是这个问题。

I've read that this happens when people try to use bcrypt on a linux env after it was built on a OS X (my OS), but I don't think that would be the issue since I'm building everything using docker and boot2docker.

推荐答案

在我的包配置中,我有bcrypt:^ 0.8.0输出 ^ 并将其更改为bcrypt:0.8.0我能够让所有的运行。

In my package config I had "bcrypt":"^0.8.0" and when I took out the ^ and changed it to "bcrypt":"0.8.0" I was able to get everything running.

问题是它试图运行bcrypt 0.8.5,这是由于某些原因导致问题。

The issue was that it was trying to run bcrypt 0.8.5 and that was causing issues for some reason.

这篇关于Bcrypt:与Docker和Sails.JS无效的ELF头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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