Add the following changes to the .env so that we use docker's mongo instead of the cloud's.
QUESTION_SVC_DB_URI=mongodb://mongodb-question:27017/question_service # docker image
USER_SVC_DB_URI=mongodb://mongodb-user:27017/user_service # docker image
This pull request introduces several changes to the docker-compose.yml file and adds initialization scripts for MongoDB databases. The key changes include adding MongoDB services and their dependencies, as well as scripts to initialize the databases with sample data.
Docker Compose Configuration:
docker-compose.yml: Added depends_on for question-service and user-service to ensure MongoDB services are started before these services. Added configurations for mongodb-question and mongodb-user services, including ports and volume mappings. [1][2]
Initialization Scripts:
init-mongo-scripts/init-mongo-questions.sh: Added a script to initialize the question_service database with 20 sample questions covering various categories and complexities.
init-mongo-scripts/init-mongo-user.sh: Added a script to initialize the user_service database with two user accounts: an admin user and a non-admin user, including their hashed passwords.
There is one mongo image for each backend service to decrease coupling.
THIS AINT GONNA SAVE YOU FROM DELETING THE ONLY ADMIN ACCOUNT.
DOCKER ISNT GOING TO SPAWN A NEW ADMIN JUST BECAUSE YOU DELETED IT.
TO SOLVE IT:
docker-compose down -v # Stops containers and removes volumes
docker-compose up --build # Rebuilds and starts the containers
env changes
Docker Compose Configuration:
docker-compose.yml
: Addeddepends_on
forquestion-service
anduser-service
to ensure MongoDB services are started before these services. Added configurations formongodb-question
andmongodb-user
services, including ports and volume mappings. [1] [2]Initialization Scripts:
init-mongo-scripts/init-mongo-questions.sh
: Added a script to initialize thequestion_service
database with 20 sample questions covering various categories and complexities.init-mongo-scripts/init-mongo-user.sh
: Added a script to initialize theuser_service
database with two user accounts: an admin user and a non-admin user, including their hashed passwords.There is one mongo image for each backend service to decrease coupling.
to connect locally on compass use these urls
mongodb://localhost:27017 mongodb://localhost:27018
LIMITATIONS:
THIS AINT GONNA SAVE YOU FROM DELETING THE ONLY ADMIN ACCOUNT. DOCKER ISNT GOING TO SPAWN A NEW ADMIN JUST BECAUSE YOU DELETED IT. TO SOLVE IT: docker-compose down -v # Stops containers and removes volumes docker-compose up --build # Rebuilds and starts the containers