version: '2'  
services:  
  nginx:
    image: nginx:latest
    container_name: ng01
    ports:
      - "8000:8000"
    volumes:
      - ./myshop:/src
      - ./config/nginx:/etc/nginx/conf.d
    depends_on:
      - web
  web:
    build: .
    container_name: dg01
    command: bash -c "python manage.py makemigrations && python manage.py migrate && gunicorn myshop.wsgi -b 0.0.0.0:8000"
    depends_on:
      - db
    volumes:
      - ./myshop:/src
      - ./myshop/static:/static
    expose:
      - "8000"

  db:
    image: postgres:latest
    container_name: ps01
    volumes:
      - db-data:/var/lib/postgresql/data
    
  redis:
    image: redis:latest
    container_name: rz01
    ports:
     - '6379:6379'

  celery:
    build: .
    container_name: cz01
    command: celery worker --app=myshop
    volumes:
      - ./myshop:/src
    links:
      - db
      - redis
volumes:
  db-data: