title: Dockerize your Angular NodeJS application
body: <p>We have an front-end application. 
  It's written in Angular (html + css + javascript) which needs to be hosted by a webserver (nginx).
  Angular is communicating with a NodeJs server which will communicate with the backend. </p>
  
  <p>Now we have to run this in Docker.</p>
  
  <ul>
  <li>We want to use 2 Docker containers: one with nodejs and one with nginx and let them work together</li>
  </ul>
  
  <p>So is it possible to write 2 dockerfiles in the one repository?
  The main idea is to have 1 dockerfile for nodejs which is also running the bower install, npm install, ...
  which will look like this:</p>
  
  <pre><code># Create app directory
  RUN mkdir -p /usr/src/www
  WORKDIR /usr/src/www
  
  RUN npm install -g bower
  RUN npm install -g gulp
  
  # Install app dependencies
  COPY . /usr/src/www/
  RUN bower install
  RUN npm install
  RUN gulp build
  
  EXPOSE port
  CMD [ "node", "server.js" ]
  </code></pre>
  
  <p>And one dockerfile in which we run a nginx-webserver but will also include a nginx.conf so it can point to the right /dist folder in our node.js-container
  The dockerfile of nginx will look like this:</p>
  
  <pre><code># Set nginx base image
  FROM nginx
  
  # Copy custom configuration file from the current directory
  COPY nginx.conf /etc/nginx/nginx.conf
  </code></pre>
  
  <p>An example of the nginx.conf</p>
  
  <pre><code>location ~* /dist {
              proxy_pass http://nodejs:port;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection 'upgrade';
              proxy_set_header Host $host;
              proxy_cache_bypass $http_upgrade;
  </code></pre>