title: Docker + fig / compose + nginx + node.js + mysql + redis
body: <p>I'm trying to set up a Node.js app on Docker multiple containers.
  My app is currently on one Ubuntu DO droplet &amp; uses: </p>
  
  <ol>
  <li>Node.js (express 4)</li>
  <li>mysql for the app database</li>
  <li>redis for a key-value store</li>
  <li>nginx for load balancing and serve static files.  </li>
  </ol>
  
  <p>I need to dockerize the different parts, one for each container obviously, then use Docker-Compose (Previously known as Fig) to simply describe the different containers &amp; setup the links between them.
  I'm steal unclear about the multi-container appraoch.<br>
  One for nginx<br>
  one for Node.js &amp; my express app<br>
  one for MySql<br>
  and one for Redis</p>
  
  <p>How would the Docker-compose.yml will look like?
  I'm guessing the nginx, mysql &amp; redis will  be unmodified official images?
  While the node.js will have a build directive to point to a Dockerfile, which will note it is based on the node.js official image along with configuration instructions?
  I will need to configure / provision mysql &amp; redis for example so does it mean that each needs to be separate with its own Dockerfile?</p>
  
  <p>What would be the way to link between the containers?
  use volumes to copy files into them, 
  setting ports, adjusting the hosts file to map some.domain.com to the nginx ip?</p>
  
  <p>I will then need to install globally some npm packages like nodemon &amp; PM2
  and set some cron jobs... (on the Node.js container?)</p>
  
  <p>here is a first draft, I would appreciate any help to better understand this new setup:</p>
  
  <p>Docker-compose.yml</p>
  
  <pre><code>nginx:
    image: nginx
    links:
      - "node"
  
  node:
    build: .
    volumes:
      - "app:/src/app"
    ports:
      - "3030:3000"
    links:
      - "db:mysql"
  
  db:
    image: mysql:5.6
    environment:
      - MYSQL_ROOT_PASSWORD=mypassword
  </code></pre>
  
  <p>Dockerfile</p>
  
  <pre><code>FROM node:0.12
  
  RUN mkdir /src
  
  RUN npm install nodemon pm2 -g
  
  WORKDIR /src
  
  ADD app/package.json /src/package.json
  
  RUN npm install
  
  ADD app/nodemon.json /src/nodemon.json
  
  EXPOSE 3000
  
  CMD npm start
  </code></pre>
  
  <p>I'm using this <a href="https://github.com/b00giZm/docker-compose-nodejs-examples/tree/master/02-express-redis-nodemon">simple project</a> as a base, though my app needs</p>