version: "3.3"

services:

  db:
    image: postgres:12.0
    environment:
      - "POSTGRES_HOST_AUTH_METHOD=trust"
    networks:
      - backend
    volumes:
      - postgres_data:/var/lib/postgresql/data/
    ports:
      - "5432:5432"

  web:
    build:
      context: .
      dockerfile: docker/Dockerfile
    command: [ "/bin/bash", "/code/compose-start.sh" ]
    depends_on:
      - db
    env_file:
      - .env
    # init: true
    networks:
      - backend
      - frontend
    ports:
      - "8000:8000"
    volumes:
      - .:/code
    stop_signal: SIGKILL

  redis:
    image: "redis:alpine"
    networks:
      - backend
    volumes:
      - redis_data:/data

  celery:
    build:
      context: .
      dockerfile: docker/Dockerfile
    command:
      [
        "/venv/bin/celery",
        "-A",
        "config",
        "worker",
        "--concurrency=10",
        "--loglevel=debug"
      ]
    depends_on:
      - db
      - redis
    env_file:
      - .env
    # init: true
    networks:
      - backend
    volumes:
      - .:/code
    stop_signal: SIGKILL

  celery-beat:
    build:
      context: .
      dockerfile: docker/Dockerfile
    command:
      [
        "/venv/bin/celery",
        "-A",
        "config",
        "beat",
        "--loglevel=debug"
      ]
    depends_on:
      - db
      - redis
    env_file:
      - .env
    # init: true
    networks:
      - backend
    volumes:
      - .:/code
    stop_signal: SIGKILL

  flower:
    build: ./
    command: python -m flower -A tasks
    volumes:
      - redis_data:/data
    working_dir: /data
    ports:
      - 5555:5555
    env_file:
      - .env

networks:
  backend:
  frontend:


volumes:
  postgres_data:
  redis_data:
