-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Added Dockerized MongoDb with Seed Data #759
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran docker-compose build then docker-compose up
We tried to run it locally with npm run start:local and got the same error
We went to the client folder and ran npm install, and then ran npm start:local again and it worked.
Still doesn't work with docker-compose up. Seems like we probably have to add sometime to docker-compose.yml or something. Working on it.
@jasonwong26 -> if you have a sec and know the answer, that would be great. Otherwise, we'll work it out. Thanks.
Hi @drubgrubby, Try deleting and recreating your docker containers - sounds like the docker environment is not pulling in the full list of modules. |
I tried deleting and re-creating the docker containers. Sadly, still getting the same errors. I tried deleting the node_modules files and running docker-compose up, but that didn't work. I ran yarn install to recreate the node_module files just in case, but still nothing. Putting this down for the moment. |
Hi David, Try the following:
I suspect the issue is that you need to fully rebuild the docker images. The FYI - I added this command to the package.json file as part of PR #762. Hope this helps! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing this pull request as stale. If anyone disagrees feel free to reopen. |
Closes #659
Closes #660
Summary
Added MongoDb container to docker environment.
Also added the new
/mongo
folder for storing the logic for generating seed data and loading it into the database. I have included aREADME.md
within that folder with details on how to use it. But to summarize:/data
folder contains a set of JSON files that store the seed data./scripts
folder contains a Node script that can be used to generate seed data usingfaker
.init.sh
file contains the commands that are run when the docker environment is started to seed the database.To retain the ability to run the project locally (without using Docker) I modified the
backend/src/config/database.config.js
file to recognize when it is being run within Docker via a new environment variable:DATABASE_HOST
. When that is provided (it is included in the Docker-Compose file), the application connects to the Mongo database within the docker environment. Otherwise it uses the pre-existingDATABASE_URL
environment variable to generate the connection string.To fully illustrate this process, I have included a new Employee data model with an associated API endpoint:
/api/employees/
. Unrelated to the MongoDb changes, I used a different way of structuring the backend code. I'd like us to discuss whether this is worth wider adoption.