version: "3"

services:

  mongo_db:
    image: mongo
    restart: always
    container_name: mongodb
    volumes:
      - db-data:/data/db
    ports:
      - 27017:27017


  middleware:
    container_name: middleware
    build:
      context: ./middleware
      dockerfile: ./Dockerfile
    command: python manage.py runserver 0.0.0.0:8000
    ports:
    - 8000:8000
    depends_on:
      - mongo_db


  frontend:
    container_name: frontend
    build:
      context: ./frontend
      dockerfile: ./Dockerfile
    ports:
      - 8080:80
    depends_on:
      - mongo_db

  iot_client:
    container_name: iot_client
    build:
      context: ./iotclient
      dockerfile: ./Dockerfile
    depends_on:
      - frontend
      - middleware
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    volumes:
      - /aic/g2:/code/images_real

volumes: 
  db-data:  # db-data is a volume that will be generated by docker compose