services:
  mongo:
    image: mongo:latest
    command: mongod --quiet --logpath /dev/null
    restart: always
    environment:
      # Provide your credentials here
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: admin
    ports:
      - 27018:27017
    volumes:
      - mongodb_data:/data/db
      - mongodb_config:/data/configdb

  mongo-express:
    image: mongo-express:latest
    restart: always
    ports:
      - 8084:8081
    environment:
      ME_CONFIG_MONGODB_URL: mongodb://admin:admin@mongo:27017/
      ME_CONFIG_BASICAUTH_USERNAME: admin
      ME_CONFIG_BASICAUTH_PASSWORD: admin
    depends_on:
      - mongo

  bc-backend:
    build: 
      context: .
      dockerfile: ./backend/Dockerfile
    env_file: ./backend/.env.docker
    restart: always
    ports:
      - 4002:4002
    depends_on:
      - mongo
    volumes:
      - cdn:/var/www/cdn/bookcars
      - backend_logs:/bookcars/backend/logs

  bc-admin:
    build: 
      context: .
      dockerfile: ./admin/Dockerfile
    depends_on:
      - bc-backend
    ports:
      - 3001:3001

  bc-frontend:
    build: 
      context: .
      dockerfile: ./frontend/Dockerfile
    depends_on:
      - bc-backend
    ports:
      - 8080:80
      - 8443:443
    volumes:
      - cdn:/var/www/cdn/bookcars

volumes:
  cdn:
  mongodb_data:
  mongodb_config:
  backend_logs:
