I've been working on a raspberry pi project where we deploy to multiple pies. We use Docker to build our images, when suddenly builds stopped working.

They would constantly hang at the same spot during npm install.

The key to solve this problem I found on this issue.

I ended up modifying the Dockerfile to update npm, and also changed the registry to use the http instead of the https endpoint.

This seemed to solve the problem, which I believe was related to network issues and how npm handles timeouts and failures.

The updated Dockerfile looks like this:

FROM hypriot/rpi-iojs:1.6.4
MAINTAINER goliatone <hello@goliatone.com>

#Actually what we want to do is just make libic2 and git available
RUN \
    apt-get update && apt-get install -y libi2c-dev git  && \
    git clone https://github.com/bryan-m-hughes/wiringPi && \
    #mkdir -p /boot && cp scripts/config.txt /boot/config.txt && \
    cd wiringPi && ./build && \
    mkdir -p /usr/src/app

WORKDIR /usr/src/app

#use changes to package.json to force Docker to not use
#cache. Use docker build --no-cache to force npm install.
ADD package.json /tmp/package.json

#update npm to latest version
RUN npm install -g npm
RUN npm update

#configure npm to use http endpoint
RUN npm config set registry http://registry.npmjs.org/ && \
    npm config set strict-ssl false

RUN cd /tmp && npm install --production -ddd
RUN cp -a /tmp/node_modules /usr/src/app/

COPY . /usr/src/app

EXPOSE 3000

CMD ["/usr/src/app/bin/daemon"]

Original Dockerfile:

FROM hypriot/rpi-iojs:1.6.4
MAINTAINER goliatone <hello@goliatone.com>

#Actually what we want to do is just make libic2 and git available
RUN \
    apt-get update && apt-get install -y libi2c-dev git  && \
    git clone https://github.com/bryan-m-hughes/wiringPi && \
    #mkdir -p /boot && cp scripts/config.txt /boot/config.txt && \
    cd wiringPi && ./build && \
    mkdir -p /usr/src/app

WORKDIR /usr/src/app

#use changes to package.json to force Docker to not use
#cache. Use docker build --no-cache to force npm install.
ADD package.json /tmp/package.json
RUN cd /tmp && npm install --production
RUN cp -a /tmp/node_modules /usr/src/app/

COPY . /usr/src/app

EXPOSE 3000

CMD ["/usr/src/app/bin/daemon"]