= DockerCompose =
 * https://docs.docker.com/compose/
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. 

== Compose test ==
 * https://docs.docker.com/compose/gettingstarted/
{{{#!highlight bash
cd ~/Documents
mkdir composetest
cd composetest
nano app.py
nano requirements.txt
nano Dockerfile
nano docker-compose.yml
docker-compose up
http://localhost:5000/

# nano app.py change hello world message. the change should be deployed in the docker container through 
the mount volume in /code
# refresh browser page 
ctrl+c
}}}

=== app.py ===
{{{#!highlight python
import time

import redis
from flask import Flask

app = Flask(__name__)
cache = redis.Redis(host='redis', port=6379)

def get_hit_count():
    retries = 5
    while True:
        try:
            return cache.incr('hits')
        except redis.exceptions.ConnectionError as exc:
            if retries == 0:
                raise exc
            retries -= 1
            time.sleep(0.5)

@app.route('/')
def hello():
    count = get_hit_count()
    return 'Hello World! I have been seen {} times.\n'.format(count)
}}}


=== requirements.txt ===
{{{
flask
redis
}}}

=== Dockerfile ===
{{{
FROM python:3.7-alpine
WORKDIR /code
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST=0.0.0.0
RUN apk add --no-cache gcc musl-dev linux-headers
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
EXPOSE 5000
COPY . .
CMD ["flask", "run"]
}}}

=== docker-compose.yml ===
{{{#!highlight yaml
version: "3.3"
services:
  web:
    build: .
    ports:
      - "5000:5000"
    volumes:
      - .:/code
    environment:
      FLASK_ENV: development
  redis:
    image: "redis:alpine"
}}}