Web app not accessible while using yarn in docker - node.js

I am trying to run a web app inside docker via yarn. Here's the docker file
FROM ubuntu:20.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -y && apt-get upgrade -y
ENV TZ=Pacific/Auckland
RUN echo $TZ > /etc/timezone && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
RUN apt-get install curl -y
RUN apt-get install npm -y
RUN apt-get install git -y
RUN npm cache clean -f
RUN npm install -g n
RUN n stable
RUN apt remove cmdtest -y
RUN apt remove yarn -y
RUN npm install -g yarn -y
RUN git config --global url."https://".insteadOf git://
EXPOSE 8080
COPY . .
RUN yarn
CMD yarn start
When I run yarn start as a non-docker the web app is accessible via localhost:8080
However when I start the docker instance via docker run -p 8080:8080 -itd webapp:latest & launch web browser & type in http://localhost:8080 the webapp isn't accessible.
Running docker logs against the container doesn't show any errors.
When I run curl, here is the error I see
curl "http://localhost:8080"
curl: (56) Recv failure: Connection reset by peer
I've no clue what is going on. Please could I request help to fix this problem.

the IP had to be bound on multiple interfaces for this to start working

Related

Docker failed to install img2pdf specifically permission denied on python3-pkg-resources

I have a docker file like this
FROM node:18
RUN apt-get update
RUN apt-get -y install img2pdf
RUN apt-get -y install dcmtk
WORKDIR /app
COPY package.json ./
RUN yarn install
RUN yarn global add pm2 -g
COPY . .
which working smoothly on my mac m1.
But when deploying it to ubuntu 22 machine,
it failed with bunch of permission denied python3-related issue
I've tried bunch of things including reiinstall python3 and python3-pkg-resources, which make my dockerfile now looks like this
FROM node:18
RUN apt-get clean
RUN apt-get update
RUN apt-get -y reinstall python3
RUN apt-get -y reinstall python3-pkg-resources
RUN apt-get -y install img2pdf
RUN apt-get -y install dcmtk
WORKDIR /app
COPY package.json ./
RUN yarn install
RUN yarn global add pm2 -g
COPY . .
now show this error
I don't have much knowledge around docker and computer CPU.
But so far my problem happens when I run the docker on intel machine. Now I move my production server using AMD vCPU. it run as local
Would be lovely if anyone have reference the reason for it. and what people could do

Not able to run the UI while running through Docker

I am not able to fetch the UI while configuring the application using Docker. I am explaining my file below.
Dockerfile::
FROM node:10-alpine as node-builder
LABEL stage=builder
COPY ./app /app
# angular build
WORKDIR /app/mean-stack/angular-js
RUN npm cache clean --force
RUN npm install --no-package-lock
RUN npm install
RUN npm run build --configuration=production
FROM dockerhub.xxx.com/as-release-docker/ubot/mongo-db:4.0.3 as mongo
LABEL stage=mongo
FROM ubuntu:20.04
LABEL maintainer="ubot-tech-team#cisco.com"
LABEL build_date="2022-08-04"
RUN apt-get update
# SET TZ
RUN apt-get install -y tzdata
RUN echo 'Asia/Kolkata' > /etc/timezone
RUN dpkg-reconfigure --frontend noninteractive tzdata
# System tools
RUN apt-get install -y --no-install-recommends nginx
RUN apt-get install -y libcurl4 curl wget openssh-client supervisor telnet
# NodeJS
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install -y nodejs
# MongoDB
COPY --from=mongo /usr/bin/mongod /usr/bin/
RUN mkdir -p /data/db
# Setup nginx
RUN useradd --no-create-home nginx
RUN rm /etc/nginx/sites-enabled/default
RUN mkdir -p /var/log/supervisor
COPY server-conf/nginx.conf /etc/nginx/
COPY server-conf/ubot-nginx.conf /etc/nginx/conf.d/
RUN echo "uwsgi_read_timeout 7200s;" > /etc/nginx/conf.d/custom_timeout.conf
COPY server-conf/uwsgi.ini /etc/uwsgi/
COPY server-conf/supervisord.conf /etc/supervisor/
# ### EXPOSE PORTS
# ngnix web
EXPOSE 90
# MongoDB
EXPOSE 27017
# node-js
EXPOSE 8081
# Cleanup
RUN apt-get remove -y wget curl
RUN apt-get clean
# TLS self-signed certs
RUN mkdir -p /etc/nginx/ssl
CMD [ "node" ]
LABEL maintainer="ubot-tech-team#cisco.com"
# ### ubot app
COPY ./app /app
RUN mkdir -p /app/static/angular/generated
COPY --from=node-builder /app/mean-stack/angular-js/dist/ubot/ /app/static/angular/
# node build
WORKDIR /app/mean-stack/node-js
RUN npm cache clean --force
RUN npm install --no-package-lock
RUN npm install
# Copy start.sh script and set +x
COPY start.sh /start.sh
RUN chmod +x /start.sh
CMD ["/start.sh"]
Here I am creating container of NODE-ANGULAR which uses nginx but its not fetching the UI and throwing the below logs.
2022-09-02 05:18:55,360 INFO success: mongod entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-02 05:18:55,360 INFO success: nginx entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-02 05:18:55,360 INFO success: node entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
2022-09-02 05:18:55,361 INFO spawnerr: can't find command '/usr/local/bin/uwsgi'
2022-09-02 05:18:57,371 INFO spawnerr: can't find command '/usr/local/bin/uwsgi'
2022-09-02 05:19:00,377 INFO spawnerr: can't find command '/usr/local/bin/uwsgi'
2022-09-02 05:19:00,377 INFO gave up: uwsgi entered FATAL state, too many start retries too quickly
Here the image is created successfully but I am not able to run the application using this container. If any expert can give the solution will be very helpfull.

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.

Issue running Gulp on Docker

I have the following Dockerfile
FROM debian:jessie
MAINTAINER Ewan Valentine <ewan#theladbible.com>
WORKDIR /tmp
RUN apt-get update -y && \
apt-get install -y \
curl
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
RUN apt-get install --yes nodejs
VOLUME ["/var/www/admin/src"]
RUN mkdir -p /var/www/admin/src
WORKDIR /var/www/admin/src
RUN npm install -g gulp
ENTRYPOINT ["gulp"]
However, when I run $ docker-compose run gulp I get the following error:
[10:47:49] Local gulp not found in /var/www/admin/src
[10:47:49] Try running: npm install gulp
I'm using docker-compose and this container is linked to a volume where the source code is kept, which all runs fine otherwise.
I was liking to the wrong volume! Sorted now.

docker command attach running slow

i have docker container that adds 3 volumes and links to one other docker container. this linked container links to another one.
the container contains a nodejs server that is listening on one port.
the time for starting up the container is very short.
if i try to attach to that container it tooks sometimes 3 minutes until the attach-command runs.
could anyone give me a reason why the attach command tooks so long to start?
This is my Dockerfile:
FROM ubuntu:trusty
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get -y install curl
RUN apt-get -y install nodejs
RUN apt-get -y install npm
RUN npm install forever -g
RUN npm install n -g
RUN n 0.11.11
RUN npm install gulp -g
RUN mkdir -p data/dmcms-static-ng
RUN mkdir -p data/site-ng
RUN mkdir -p data/static-ng
ADD app-run.sh /app-run.sh
RUN chmod 755 /*.sh

Resources