我有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
问题,因为我正在安装最新版本。
我该如何解决这个问题?
答案 0 :(得分:0)
想出来了。 是一个遗留问题。需要像这样添加Debian nodejs-legacy symlink package:
RUN apt-get update && apt-get install -y git nodejs npm htop nodejs-legacy
然后构建运行没有问题。