Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docker for mongo #158

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add docker for mongo #158

wants to merge 3 commits into from

Conversation

TanPingZhi
Copy link

@TanPingZhi TanPingZhi commented Oct 6, 2024

env changes

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:

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

@jq1836 jq1836 self-requested a review October 6, 2024 14:28
Copy link

@jq1836 jq1836 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants