Node version not upgrading - node.js

I am trying to upgrade the node version to meet other dependencies of my project. And I have tried various methods to find a proper solution. But unfortunately, nothing is working. I end up trying this
and no change in the response.
My current node version is v0.10.33. This is actually implemented on docker. I am attaching the docker file below.
FROM node:6.2.1
RUN apt-get update --fix-missing
RUN apt-get install -y supervisor
RUN apt-get install -y python-pip && pip install supervisor-stdout
# Cleanup
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN apt-get autoremove -y
#ADD ./config/supervisord.conf /etc/supervisor/conf.d/supervisord- nodejs.conf
RUN ln -s /usr/bin/nodejs /usr/local/bin/node
ADD package.json /
ONBUILD RUN npm install
WORKDIR /app
ADD . /app
RUN npm update
EXPOSE 8080
CMD ["/usr/bin/supervisord", "-n"]
#ENTRYPOINT ["/nodejs/bin/npm", "start"]
Since I am not pretty good at docker and node don't what is happening. Even though docker file started with From node:6.2.1 the node version instaling is v0.10.33. And that is a weird thing I am experiencing. All kinda help are appreciated.

The ln -s is the wrong way around and should be failing.
Step 7 : RUN ln -s /usr/bin/nodejs /usr/local/bin/node
---> Running in 4f1e92a58fe8
ln: failed to create symbolic link '/usr/local/bin/node': File exists
The command '/bin/sh -c ln -s /usr/bin/nodejs /usr/local/bin/node' returned a non-zero code: 1
If you hadn't noticed this error then you would be running the old image still with node v0.10.33.
Change that line to
RUN ln -s /usr/local/bin/node /usr/bin/nodejs
If this is part of some build scripts, always check the exit status of your commands. In bash, $? will give you the return code or set -e will automagically check return codes for you.

Related

Error using Oracle Instant Client Docker image

our app is nodejs based and needs to query Oracle DB, so we install NPM oracledb package. So our Docker image is based on oracle instant client, the Docker file looks like following:
FROM frolvlad/alpine-glibc
RUN apk update && apk add libaio
COPY instantclient_12_1.zip ./
RUN unzip instantclient_12_1.zip
RUN mv instantclient_12_1/ /usr/lib/
RUN rm instantclient_12_1.zip
RUN ln /usr/lib/instantclient_12_1/libclntsh.so.12.1 /usr/lib/libclntsh.so
RUN ln /usr/lib/instantclient_12_1/libocci.so.12.1 /usr/lib/libocci.so
RUN ln /usr/lib/instantclient_12_1/libociei.so /usr/lib/libociei.so
RUN ln /usr/lib/instantclient_12_1/libnnz12.so /usr/lib/libnnz12.so
ENV ORACLE_BASE /usr/lib/instantclient_12_1
ENV LD_LIBRARY_PATH /usr/lib/instantclient_12_1
ENV TNS_ADMIN /usr/lib/instantclient_12_1
ENV ORACLE_HOME /usr/lib/instantclient_12_1
RUN apk add nodejs npm
RUN mkdir -p /var/app
WORKDIR /var/app
ADD package.json /var/app
COPY . /var/app
CMD ["npm","start"]
But when our app starts using 'oracledb' NPM package, it got following error:
init() error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "Error loading shared library libnsl.so.1: No such file or directory (needed by /usr/lib/libclntsh.so)". See https://oracle.github.io/odpi/doc/installation.html#linux for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
So Oracle client couldn't find libnsl.so.1 even thought it should come with glibc, and I can see that it is under:
'/usr/glibc-compat/lib'.
Any ideas how to fix this? Thanks in Advance.
# 1. Install dependencies
FROM node:8.15 as cache-package
COPY package.json /srv/src/package.json
WORKDIR /srv/src
RUN yarn install
# 2.
FROM node:8.15 as builder
# 1. Update everything on the box
RUN apt-get update && \
apt-get install sudo
#RUN apk --update add libaio bc net-tools
RUN sudo apt-get install unzip
RUN sudo apt-get install wget
RUN sudo apt-get install git
# 3. Install oracle client
RUN mkdir -p /opt/oracle
# 3.1 Get oracle client
WORKDIR /opt/oracle
RUN wget -O /opt/oracle/instantclient_18_3_linux.zip http://YOUR_URL_TO_DOWNLOAD_THE_CLIENT/instantclient_18_3_linux.zip
RUN sudo unzip /opt/oracle/instantclient_18_3_linux.zip
# 3.2 Configure oracle client to work with node
RUN sudo sh -c "echo /opt/oracle/instantclient_18_3_linux > /etc/ld.so.conf.d/oracle-instantclient.conf"
RUN sudo cat /etc/ld.so.conf.d/oracle-instantclient.conf
FROM node:8.15
RUN apt-get update && \
apt-get install sudo
RUN sudo apt-get install libaio1
RUN mkdir -p /srv/src/logs
RUN mkdir -p /srv/logs
RUN mkdir -p /opt/oracle
# 4. Set the working directory
# 5. Copy our project & install our dependencies
COPY --from=cache-package /srv/src /srv/src
COPY --from=builder /opt/oracle/instantclient_18_3_linux /opt/oracle/instantclient_18_3_linux
COPY --from=builder /etc/ld.so.conf.d/oracle-instantclient.conf /etc/ld.so.conf.d/oracle-instantclient.conf
RUN sudo ldconfig
RUN ln -sf /usr/share/zoneinfo/WET /etc/localtime
COPY . /srv/src
WORKDIR /srv/src
# 6. Start the app
CMD yarn start
Here is my dockerfile working fine, the srv/src is my directory where I have my code, just change for yours and it should work.
I have the same problem as you the past two days and now it works.

Docker error returned a non-zero code: 1 while building docker image

When I try to build the docker, I get an error like "/bin/sh -c returned a non-zero code: 1 ".
Here is the dockerfile which I have created
FROM tomcat:7.0.82-jre8
WORKDIR /usr/local/tomcat
COPY /app.war /usr/local/tomcat/webapps/app.war
RUN apt-get update && apt-get -y upgrade && apt-get install -y dos2unix
RUN unzip /usr/local/tomcat/webapps/app.war -d /usr/local/tomcat/webapps/app
EXPOSE 8080
COPY tomcat-users.xml /usr/local/tomcat/conf/
COPY test1.xml /usr/local/tomcat/webapps/app/conf/services/
COPY doc.properties /usr/local/tomcat/webapps/app/conf/services/properties/
COPY springConfig.xml /usr/local/tomcat/webapps/app/conf/quartz/
COPY test.properties /usr/local/tomcat/webapps/app/conf
ENV JAVA_OPTS="-Xms2G -Xmx2G"
# Copy Entrypoint script in the container
COPY ./docker-entrypoint.sh /
RUN dos2unix /docker-entrypoint.sh && apt-get --purge remove -y dos2unix && rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["/docker-entrypoint.sh"]
When I try to build the docker image based on the above dockerfile, I get an error like this
ERROR: Service 'app' failed to build: The command '/bin/sh -c unzip /usr/local/tomcat/webapps/app.war -d /usr/local/tomcat/webapps/app' returned a non-zero code: 1
I am not sure what is causing this issue. I went through couple of stackoverflow posts with similar kind of error and tried those solutions, but no luck on that. Between this dockerfile was working before, but for some reason I get this error now.
Any help on this would be appreciable.

Deploying node.js web app along with docker

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:Admin23#github.com/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"
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"]
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.

Docker with Node.js and Express.js

I'm trying to use docker with my node application, my Dockerfile looks like this:
RUN apt-get update
RUN apt-get -y install build-essential
RUN apt-get install -y nodejs
RUN apt-get install -y npm
ADD . /src
RUN cd /src && npm install
EXPOSE 8080
CMD ["node","/src/app.js"]
but after running docker build when npm install is running after trying to install https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz I get an error:
The command 'bin/sh -c /src && npm install' returned a non-zero code : 1
What can cause such an issue? I've already tried to install node-legacy instead of node and it didn't work
Try this:
# put this line on your code (if you are using ubuntu)
# this make a link from nodejs to node to add compatibility on ubuntu OS
RUN ln -s /usr/bin/nodejs /usr/bin/node
# set your current directory with WORKDIR
WORKDIR /src
RUN sudo npm install

Getting error installing nodejs when building from docker

I am trying to install nodejs using the docker console for ubuntu but I get an error installing node js. This is the error I am getting
The command [/bin/sh -c ./configure && make && make install] returned a non-zero code: 127
This is part of my dockerfile
FROM ubuntu:12.04
RUN mkdir -p /dir/subdir
RUN apt-get update
# Install nodejs
ADD http://nodejs.org/dist/v0.10.26/node-v0.10.26-linux-x64.tar.gz /dir
WORKDIR /dir/node-v0.10.26-linux-x64
RUN ./configure && make && make install
WORKDIR /dir
Exit code 127 typically means "command not found". Chances are build-essentials are not installed.
Try adding the following after the apt-get update:
RUN apt-get -y install build-essential

Resources