version: '3'
services:
  portal:
    build: .
    image: 'kontr2/portal'
    command: bash docker_run.sh
    ports:
    - "8000:8000"
    environment:
      CELERY_BROKER_URL: "redis://redis:6379/0"
      SQLALCHEMY_DATABASE_URI: "postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_DB}"
    networks:
    - async_nw
    - db_nw
    depends_on:
    - db
    - redis

  celery:
    image: 'kontr2/portal'
    container_name: 'kontr-portal-async-celery'
    command: "celery worker -l info -A app.celery"
    environment:
      CELERY_BROKER_URL: 'redis://redis:6379/0'
      SQLALCHEMY_DATABASE_URI: "postgresql://${DB_USER}:${DB_PASSWORD}@db:5432/${DB_DB}"
    depends_on:
    - redis
    - portal
    - db
    networks:
    - async_nw
    - db_nw


  redis:
    image: "redis:alpine"
    networks:
    - async_nw

  db:
    image: 'postgres'
    ports:
    - "5432:5432"
    networks:
    - db_nw
    environment:
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_DB: ${DB_DB}
networks:
  db_nw:
    driver: bridge
  async_nw:
    driver: bridge