services:
  backend: &backend
    build:
      context: ./
      dockerfile: ./backend/Dockerfile.development
    command:
      - /sebn-inventory/backend/manage.py
      - runserver
      - 0.0.0.0:8000
    environment:
      - TZ
      - MYSQL_ROOT_PASSWORD
      - MYSQL_DATABASE
      - MYSQL_USER
      - MYSQL_PASSWORD
      - MYSQL_HOST
      - MYSQL_PORT
      - BACKEND_HOST
      - BACKEND_PORT
      - CELERY_BROKER
      - LANG
      - SECRET_KEY
      - LDAP_BIND_DN
      - LDAP_BIND_PASSWORD
      - LDAP_PORT
      - LDAP_HOST
      - LDAP_BASE
      - LDAP_ADMINS

    image: sebn-inventory/backend:development
    ports:
      - "8000:8000"
    tty: true
    volumes:
      - ./backend:/sebn-inventory/backend
      - ./celery/celery.sh:/sebn-inventory/celery.sh
  frontend:
    build:
      context: ./
      dockerfile: ./frontend/Dockerfile.development
    command:
      - npm
      - start
    environment:
      - CHOKIDAR_USEPOLLING
      - REACT_APP_BACKEND_URL
      - REACT_APP_NAME
      - REACT_APP_VERSION
      - FAST_REFRESH

    image: sebn-inventory/frontend:development
    ports:
      - "3000:3000"
    stdin_open: true
    volumes:
      - ./frontend:/sebn-inventory/frontend
  flutter-frontend:
    build:
      context: ./
      dockerfile: ./flutter-frontend/Dockerfile.development
    image: sebn-inventory/flutter-frontend:latest
    ports:
      - "3001:3001"
    volumes:
      - ./flutter-frontend:/sebn-inventory/flutter-frontend
  task-queue:
    <<: *backend
    command:
      - /sebn-inventory/celery.sh
    ports: []
    volumes:
      - ./celery/celery.sh:/sebn-inventory/celery.sh
      - ./backend:/sebn-inventory/backend
    tty: false
  broker:
    image: rabbitmq:3
    environment:
      - RABBITMQ_DEFAULT_USER
      - RABBITMQ_DEFAULT_PASS

  db:
    image: mysql:latest
    cap_add:
      - SYS_NICE
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD
      - MYSQL_DATABASE
      - MYSQL_USER
      - MYSQL_PASSWORD
      - MYSQL_HOST
      - MYSQL_PORT
    command: >
      --default-authentication-plugin=mysql_native_password
      --federated
      --log-timestamps=SYSTEM
    volumes:
      - ./db:/var/lib/mysql

version: "3.3"
