0

WE have a node.js web app.We have deployed it on server with docker. Its working fine with node version 0.10.25. But right now i have decided it to run on latest version of node 6.5.0

To accomplish this i modified the docker file which is now looking like below

FROM ubuntu:14.04
RUN echo 'deb http://security.ubuntu.com/ubuntu trusty-security main' | sudo tee -a /etc/apt/sources.list
RUN sudo apt-get update
RUN sudo apt-get install  linux-libc-dev  curl  git-core krb5-multidev libkrb5-dev -y
RUN sudo curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN sudo apt-get install  nodejs -y
RUN sudo ln -sf /usr/bin/nodejs /usr/bin/node
RUN ["/bin/bash", "-c", "node -v"]
RUN sudo npm cache clean
RUN sudo npm install -g bower -y
RUN sudo npm install -g gulp -y
#RUN sudo npm install -g node-sass
#RUN sudo npm install -g eslint -y
#RUN sudo npm install -g htmllint -y
RUN cd /root; git clone -b masterclone  https://consultancy:[email protected]/newapp/web.git
RUN cd /root/web; sudo npm install; sudo bower install --allow-root; gulp clean-build-app-prod
EXPOSE 8000
CMD cd /root/web; NODE_ENV=production node server.js

Everything went fine except the below line which i guess causing the problem

   "The command '/bin/sh -c cd /root/web; sudo npm install; sudo bower install --allow-root; gulp clean-build-app-prod' returned a non-zero code: 1"

2 Answers 2

1

Use the official node image. Here a example file.

FROM node:6.5

# Enviroment variables
ENV NPM_CONFIG_LOGLEVEL warn
ENV USER node
ENV HOMEDIR /data

# add user node and change dir working dir
RUN useradd -ms /bin/bash ${USER}
RUN mkdir -p ${HOMEDIR}
WORKDIR ${HOMEDIR}

# install all dependencies
COPY package.json ./
RUN npm install --production

# add node content
COPY . .

USER node
EXPOSE 8000

CMD ["npm", "start"]
Sign up to request clarification or add additional context in comments.

Comments

0

It's probably simpler to base your file off of the official NodeJS image. For v6.5, that means that FROM ubuntu:14.04 becomes FROM node:6.5.

Also, instead of doing RUN cd /root/web over and over, you might want to change the working directory with WORKDIR /root/web.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.