title: Django microservices within Docker
body: <p>I have the following <code>docker-compose.yml</code>:</p>
  
  <pre><code>version: '3.6'
  
  services:
    db:
      image: postgres:10.4
      volumes:
        - postgres_data:/var/lib/postgresql/data/
    cache:
      image: redis:4.0.10
      volumes:
        - redis_data:/data
    web:
      build: .
      image: dockerdjangoexample
      command: bash -c "gunicorn demosite.wsgi:application -b 0.0.0.0:8000"
      volumes:
        - .:/code
      depends_on:
        - db
        - cache
    nginx:
      image: nginx:1.15.2-alpine
      ports:
        - "8000:8000"
      volumes:
        - ./docker-config/nginx:/etc/nginx/conf.d
      depends_on:
        - web
  
  volumes:
    postgres_data:
    redis_data:
  </code></pre>
  
  <p>The <code>Dockerfile</code> is:</p>
  
  <pre><code>FROM python:3.6.5
  
  ENV PYTHONDONTWRITEBYTECODE 1
  ENV PYTHONUNBUFFERED 1
  
  WORKDIR /code
  COPY . /code/
  
  RUN pip install --upgrade pip
  RUN pip install pipenv
  RUN pipenv install --deploy --system --skip-lock --dev
  </code></pre>
  
  <p>The <code>Nginx</code> config file is:</p>
  
  <pre><code>upstream web {
    ip_hash;
    server web:8000;
  }
  
  server {
    location / {
           proxy_pass http://web/;
    }
    listen 8000;
    server_name localhost;
  }
  </code></pre>
  
  <p>This all works perfectly. What im trying to figure out now is how I can add a second <code>Django</code> app into the mix so I can create a microservice environment.</p>
  
  <p>For example, the existing web app from above would be an API that handles user registration / sign in etc. I would like to add another <code>Django</code> API into the mix that would do something else and would also use its own database.</p>
  
  <p>If this were to theoretically ever be put into a production environment, then the first API would be used through urls starting with <code>www.demosite.com/api/users</code> and the second API could be used through urls starting with <code>www.demosite.com/api/widgets</code>.</p>
  
  <p>Im not sure how to accomplish this from a <code>Docker</code> and <code>Nginx</code> perspective.</p>
  
  <p>Also, if im doing anything completely wrong so far, please correct me as I am new to this.</p>