0

我有一个Dockerfile看起来像这样的:

FROM ubuntu:14.04
MAINTAINER Firstname Lastname <email@myapp.com>

ENV NODE_ENV production
ENV PORT 3333

RUN apt-get update && apt-get install -y git nodejs npm htop

RUN mkdir /root/.ssh/ && \
    touch /root/.ssh/known_hosts && \
    ssh-keyscan github.com >> /root/.ssh/known_hosts

ADD .ssh/my-github-deploy-key /root/.ssh/my-github-deploy-key
ADD .ssh/config /root/.ssh/config

RUN chmod 600 /root/.ssh/my-github-deploy-key && \
    chmod 600 /root/.ssh/config && \
    chown -R root:root /root/.ssh

RUN mkdir /srv/MyAppName && \
    cd /srv && \
    git clone git@github.com:MyAccountName/MyAppName.git MyAppName && \
    cd MyAppName && \
    npm install

EXPOSE 3333

CMD ["nodejs","/srv/MyAppName/index.js"]

而且我已经将我的Dockerhub回购连接到我的Github回购,这样Automated Build每次我推送到我的主分支时都会触发一个。

但是构建失败了,这可能是由于npm install bcrypt命令造成的。我在构建日志中收到以下错误:

gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
Error: `gyp` failed with exit code: 1 at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
ERR! at ChildProcess.EventEmitter.emit (events.js:98:17)
ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
ERR! System Linux 3.14.27
ERR!command "nodejs" "/usr/bin/node-gyp" "rebuild"
ERR! cwd /srv/MyApp/node_modules/bcrypt
ERR! node -v v0.10.25
ERR! node-gyp -v v0.10.10
ERR! not ok 
npm WARN This failure might be due to the use of legacy binary "node"

我不确定为什么这会是一个legacy binary node问题,因为我正在安装最新版本。

我该如何解决这个问题?

4

1 回答 1

0

想通了。这一个 nodejs 遗留问题。需要像这样添加Debian nodejs-legacy 符号链接包

RUN apt-get update && apt-get install -y git nodejs npm htop nodejs-legacy

然后构建运行没有问题。

于 2015-01-12T08:59:44.037 回答