fix(docker): Update dockerfile for development and production (#1491)

* Fix(#1468) - Corrected SYNTAX some fixes

* Fix(#1468) - Fix(#1453) - Corrected SYNTAX some fixes for production and fix this bug #1453

* Fix(#1453) - Add .dockerignore

* Update Dockerfile-production

* Update Dockerfile development
This commit is contained in:
Federico Gonzalez
2016-09-09 02:28:07 -03:00
committed by Liran Tal
parent 1a274d2675
commit e25670a418
3 changed files with 83 additions and 57 deletions

4
.dockerignore Normal file
View File

@@ -0,0 +1,4 @@
node_modules
bower_components
.tmp
.env

View File

@@ -10,22 +10,52 @@
FROM ubuntu:latest
MAINTAINER MEAN.JS
# 80 = HTTP, 443 = HTTPS, 3000 = MEAN.JS server, 35729 = livereload
EXPOSE 80 443 3000 35729
# Set development environment as default
ENV NODE_ENV development
# Install Utilities
RUN apt-get update -q
RUN apt-get install -yqq wget aptitude htop vim git traceroute dnsutils curl ssh sudo tree tcpdump nano psmisc gcc make build-essential libfreetype6 libfontconfig libkrb5-dev
RUN apt-get update -q \
&& apt-get install -yqq curl \
wget \
aptitude \
htop \
vim \
git \
traceroute \
dnsutils \
curl \
ssh \
tree \
tcpdump \
nano \
psmisc \
gcc \
make \
build-essential \
libfreetype6 \
libfontconfig \
libkrb5-dev \
ruby \
sudo \
apt-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install gem sass for grunt-contrib-sass
RUN apt-get install -y ruby
RUN gem install sass
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs
# Install MEAN.JS Prerequisites
RUN npm install --quiet -g grunt-cli gulp bower yo mocha karma-cli pm2
RUN npm install --quiet -g grunt-cli gulp bower yo mocha karma-cli pm2 && npm cache clean
RUN mkdir /opt/mean.js
RUN mkdir -p /opt/mean.js/public/lib
WORKDIR /opt/mean.js
@@ -35,35 +65,14 @@ WORKDIR /opt/mean.js
# when the local package.json file changes.
# Install npm packages
ADD package.json /opt/mean.js/package.json
RUN npm install --quiet
RUN npm install --quiet && npm cache clean
# Install bower packages
ADD bower.json /opt/mean.js/bower.json
ADD .bowerrc /opt/mean.js/.bowerrc
RUN bower install --quiet --allow-root --config.interactive=false
# Share local directory on the docker container
ADD . /opt/mean.js
# Machine cleanup
RUN npm cache clean
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set development environment as default
ENV NODE_ENV development
# Ports generic
EXPOSE 80:80
EXPOSE 443:443
# Port 3000 for MEAN.JS server
EXPOSE 3000:3000
# Port 5858 for node debug
EXPOSE 5858:5858
# Port 35729 for livereload
EXPOSE 35729:35729
# Run MEAN.JS server
CMD ["npm", "start"]

View File

@@ -10,21 +10,49 @@
FROM ubuntu:latest
MAINTAINER MEAN.JS
# 80 = HTTP, 443 = HTTPS, 3000 = MEAN.JS server, 35729 = livereload
EXPOSE 80 443 3000 35729
# Install Utilities
RUN apt-get update -q && apt-get install -yqq aptitude git traceroute dnsutils tree tcpdump psmisc gcc make build-essential libfreetype6 libfontconfig libkrb5-dev curl sudo
RUN apt-get update -q \
&& apt-get install -yqq curl \
wget \
aptitude \
htop \
vim \
git \
traceroute \
dnsutils \
curl \
ssh \
tree \
tcpdump \
nano \
psmisc \
gcc \
make \
build-essential \
libfreetype6 \
libfontconfig \
libkrb5-dev \
ruby \
sudo \
apt-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install gem sass for grunt-contrib-sass
RUN apt-get install -y ruby
RUN gem install sass
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs
# Install MEAN.JS Prerequisites
RUN npm install --quiet -g grunt-cli gulp bower yo mocha karma-cli pm2
RUN npm install --quiet -g grunt-cli gulp bower yo mocha karma-cli pm2 && npm cache clean
RUN mkdir /opt/mean.js
RUN mkdir -p /opt/mean.js/public/lib
WORKDIR /opt/mean.js
@@ -34,32 +62,17 @@ WORKDIR /opt/mean.js
# when the local package.json file changes.
# Install npm packages
ADD package.json /opt/mean.js/package.json
RUN NODE_ENV=development npm install --quiet
RUN NODE_ENV=development npm install --quiet && npm cache clean
# Install bower packages
ADD bower.json /opt/mean.js/bower.json
ADD .bowerrc /opt/mean.js/.bowerrc
RUN bower install --quiet --allow-root --config.interactive=false
# Share local directory on the docker container
ADD . /opt/mean.js
# Machine cleanup
RUN npm cache clean
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Set development environment as default
ENV NODE_ENV production
# Ports generic
EXPOSE 80:80
EXPOSE 443:443
# Port 3000 for MEAN.JS server
EXPOSE 3000:3000
# Port 35729 for livereload
EXPOSE 35729:35729
ADD . /opt/mean.js
# Run MEAN.JS server
CMD ["npm","run-script","start:prod"]
CMD ["npm","run-script","start:prod"]