Skip to content

Instantly share code, notes, and snippets.

@RinatMullayanov
Last active August 1, 2023 22:13
Show Gist options
  • Star 39 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save RinatMullayanov/89687a102e696b1d4cab to your computer and use it in GitHub Desktop.
Save RinatMullayanov/89687a102e696b1d4cab to your computer and use it in GitHub Desktop.
Ubuntu Node.js Dockerfile
#
# Ubuntu Node.js Dockerfile
#
# https://github.com/dockerfile/ubuntu/blob/master/Dockerfile
# https://docs.docker.com/examples/nodejs_web_app/
#
# Pull base image.
FROM ubuntu:14.04
# Install Node.js
RUN apt-get install --yes curl
RUN curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
# Bundle app source
# Trouble with COPY http://stackoverflow.com/a/30405787/2926832
COPY . /src
# Install app dependencies
RUN cd /src; npm install
# Binds to port 8080
EXPOSE 8080
# Defines your runtime(define default command)
# These commands unlike RUN (they are carried out in the construction of the container) are run when the container
CMD ["node", "/src/index.js"]
@ArthurOliverB
Copy link

Thank you very much! You saved my life!!!

@scones
Copy link

scones commented Apr 10, 2018

you don't need sudo tho

@dequn
Copy link

dequn commented Apr 20, 2018

Thank you !

@nvaklinov
Copy link

Thank you! You are awesome!

@aic25
Copy link

aic25 commented Aug 27, 2018

THANK YOU!!

@designbyadrian
Copy link

#  Defines your runtime(define default command)
# These commands unlike RUN (they are carried out in the construction of the container) are run when the container

Some comments are missing.

@Venkat003
Copy link

I need to install node.js 8.12.0 inside docker file
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get -y install nodejs
I have tried with these two commands but error response 100, I got
Can anyone may be help on this.

@nmiddleton
Copy link

You need the HTTP transport first otherwise you will get 100 response
Put this line at the top of the apt-gets.

RUN apt-get update && apt-get install -y apt-transport-https

@RaptorialThing
Copy link

RaptorialThing commented Nov 16, 2020

Ohh thx you. I tried install yarn on my Dockerfile but it didn work. Now with apt-transport-https its work!
Great. Thank you

RUN curl --silent --location https://deb.nodesource.com/setup_4.x |  bash -
RUN apt-get install -y apt-transport-https --yes node
RUN apt-get install --yes build-essential
COPY . /var/www/

RUN cd /var/www; npm install -g yarn

UPD: Finally version
You want add yarn? Just add to your dockerfile


RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg |  apt-key add - \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | dd of=/etc/apt/sources.list.d/yarn.list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment