version: '3.8'

services:
  app:
    image: drugstone_backend
    container_name: drugstone_backend
    command: 
      - "sh"
      - "/usr/src/drugstone/docker-entrypoint.sh"
    build: .
    env_file:
      - 'docker-django.env.dev'
    restart: always
    volumes:
      - ./:/usr/src/drugstone/
    ports:
      - 8001:8000
    networks:
      - drugstone_net
    depends_on:
      - db
      - redis
  db:
    image: postgres
    container_name: drugstone_postgres
    restart: always
    hostname: drugstone_postgres
    ports:
      - 5432:5432
    networks:
      - drugstone_net
    volumes:
      - drugstone_postgres_volume:/var/lib/postgresql/data_drugstone/
    environment:
      - POSTGRES_DB=drugstone
      - POSTGRES_USER=drugstone
      - POSTGRES_PASSWORD=t6278yczAH7rPKVMxaDD
    command: 
      - "postgres"
      - "-c" 
      - "max_connections=10000"
      - "-c"
      - "shared_buffers=2GB"
  redis:
    image: redis
    container_name: drugstone_redis
    restart: always
    command: ["redis-server"]
    networks:
      - drugstone_net
    ports:
      - 6379:6379
  celery:
    command: 
      - "sh"
      - "/usr/src/drugstone/scripts/start_celery_worker.sh"
    restart: always
    build: .
    container_name: drugstone_celery
    hostname: drugstone_celery
    env_file:
      - './docker-django.env.dev'
    volumes:
      - ./:/usr/src/drugstone/
    depends_on:
      - redis
      - db
    networks:
      - drugstone_net
  celery-beat:
    command: 
      - "sh"
      - "/usr/src/drugstone/scripts/start_celery_beat.sh"
    build: .
    container_name: drugstone_celery_beat
    hostname: drugstone_celery_beat
    env_file:
      - './docker-django.env.dev'
    volumes:
      - ./:/usr/src/drugstone/
    depends_on:
      - redis
      - db
    networks:
      - drugstone_net
  flower:  
    image: mher/flower
    container_name: drugstone_flower
    env_file:
      - './docker-django.env.dev'
    ports:  
      - 8888:8888
    networks:
      - drugstone_net

networks:
  drugstone_net:

volumes:
  drugstone_postgres_volume: