0

I've got a Dockerfile that looks like so:

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"]

And I've got my Dockerhub repo wired up to my Github repo so that an Automated Build is triggered each time I push to my master branch.

But the build is failing, and it's likely due to the npm install bcrypt command. I get the following error in the build log:

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"

I'm not sure why this would be a legacy binary node issue since I'm installing the latest version.

How do I work around this?

AJB
  • 7,389
  • 14
  • 57
  • 88

1 Answers1

0

Figured this out. It was a nodejs legacy issue. Needed to add the Debian nodejs-legacy symlink package like so:

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

And then the build ran without issue.

AJB
  • 7,389
  • 14
  • 57
  • 88