version: "3"
volumes:
  postgres-data:
  static-files:
  node-modules:

services:
  db:
    image: postgres
    environment:
      POSTGRES_DB: "newsreader"
      POSTGRES_USER: "newsreader"
      POSTGRES_PASSWORD: "newsreader"
    volumes:
      - postgres-data:/var/lib/postgresql/data
  rabbitmq:
    image: rabbitmq:3.7
  memcached:
    image: memcached:1.6
    ports:
      - "11211:11211"
    entrypoint:
      - memcached
      - -m 64
  celery:
    build:
      context: .
      dockerfile: ./docker/django
    command: celery worker -n worker1@%h -n worker2@%h --app newsreader --loglevel INFO --concurrency 2 --workdir /app/src/ --beat --scheduler django
    environment:
      - DJANGO_SETTINGS_MODULE=newsreader.conf.docker
    depends_on:
      - rabbitmq
      - memcached
    volumes:
      - .:/app
  django:
    build:
      context: .
      dockerfile: ./docker/django
    command: python /app/src/manage.py runserver 0.0.0.0:8000
    environment:
      - DJANGO_SETTINGS_MODULE=newsreader.conf.docker
    ports:
      - "8000:8000"
    depends_on:
      - db
      - memcached
    volumes:
      - .:/app
      - static-files:/app/src/newsreader/static
    stdin_open: true
    tty: true
  webpack:
    build:
      context: .
      dockerfile: ./docker/webpack
    command: npm run build:watch
    volumes:
      - .:/app
      - static-files:/app/src/newsreader/static
      - node-modules:/app/node_modules
