version: '3'

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/app
    ports:
      - "8000:8000"
    depends_on:
      - app_migrations

  geetham_container:
    image: mongo
    restart: on-failure
    container_name: geetham_container
    environment:
      - MONGO_INITDB_ROOT_USERNAME=geetham_container
      - MONGO_INITDB_ROOT_PASSWORD=Geeth@mVeG!2
      - MONGO_INITDB_DATABASE=geetham_container
      - MONGO_INITDB_USERNAME=geetham_container
      - MONGO_INITDB_PASSWORD=Geeth@mVeG!2
    ports:
      - "27017:27017"

  app_migrations:
    build: .
    image: app
    container_name: app_migrations
    command: python manage.py migrate
    volumes:
      - .:/app
    links:
      - geetham_container
    depends_on:
      - app_make_migrations_all

  app_make_migrations_all:
    build: .
    image: app
    container_name: app_make_migrations_all
    command: python manage.py makemigrations
    volumes:
      - .:/app
    links:
      - geetham_container
    depends_on:
      - geetham_container
#db.createUser({user:"geetham_container", pwd:"Geeth@mVeG!2", roles:[{role:"root", db:"admin"}]})