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

[CHE-193] Create and Seed Mongo Container for Dev #145

Merged

Conversation

seantokuzo
Copy link
Contributor

Description

As part of the General Improvements story this PR aims to enhance the Codehammers™ developer experience. What it do?

  • Define a mongo database service in docker-compose-dev - this service creates an instance of MongoDB running in a docker container usable by our application in development
  • Define all necessary environmental variables for the dev container in its docker-compose file - no more need for a .env file
  • Creates scripts that are placed into the mongo dev container that seed the dev database with mock data on startup
  • Creates a named volume for mongo data. This allows data to persist if you stop and restart the mongo-dev service. This data persistence enables the mongo-dev container to skip the seeding phase, making subsequent startups quicker
  • Exposes port 3000 on the development container for manual testing with Postman

Jira Task

JIRA TICKET

Testing Instructions

  • run npm run docker-remove-all to remove existing containers/images/volumes
  • run npm run docker-build-check to check linting and unit tests still pass
  • run npm run docker-dev
  • navigate to http://localhost:8080
  • login with test user: email = [email protected], password = ilovetesting
  • navigate to alumni/profiles/forums pages and check that mock data has populated

For fun

  • While docker-dev is running open up a terminal
  • Run docker exec -it ch-mongo-dev mongosh -u admin -p adminpassword - this will allow you to run commands with mongosh inside of the docker container
  • run use ch-testdb to switch to our development database
  • run db.users.find() - this should return all of our mock users that have been seeded into the development database
  • run the same command as above but with any other collection name (eg. db.<collection_name>.find()) - our collection names are: users, alumnis, graduateinvitations, profiles, forums, threads, posts
  • you can also query for specific documents: eg. db.users.find({email: "[email protected]"})

Checklist

All Team Members

  • I added a descriptive title to this PR.
  • I filled out the Description, Jira Task, and Testing Instructions sections above.
  • I added or updated [Jest unit tests]for any changes to components, server-side controllers, etc.
  • I ran npm run docker-test in my local environment to check that this PR passes all unit tests.
  • I did a quick check to make sure my code changes follow the recomended style guide.

Copy link

@serenahromano serenahromano left a comment

Choose a reason for hiding this comment

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

nice!

Copy link
Contributor

@brok3turtl3 brok3turtl3 left a comment

Choose a reason for hiding this comment

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

Love the scripts here @seantokuzo - nice work! 🎉

❔ We can continue the conversation about this outside this ticket but a 37k line file leaves me uneasy lol...

🛑 Need to add our three core testing accounts listed in the readme to our seeder data and attribute some of the threads and posts to them

🛑 When I spin things up as per the instructions none of the image pulls work. Attaching some ss's. Is there a way to get your stock images to show up in dev mode when the S3 credentials have been disabled?
Screenshot 2024-06-16 at 8 38 30 AM
Screenshot 2024-06-16 at 8 48 09 AM

image: codehammers/ch-dev-dep-v3:latest
container_name: ch-dev
ports:
- '8080:8080'
- '3000:3000'
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Comment on lines 1 to 18
[
{
"firstName": "Testy",
"lastName": "McTesterson",
"email": "[email protected]",
"profilePic": "https://www.codesmith.io/hubfs/Screen%20Shot%202024-06-10%20at%2010.46.24%20AM.png",
"password": "$2a$10$LGAtDH0sMsL39sZxWRN8r.X.//5/XBIirtADsSg9VLUciCxXhmtF.",
"_id": {
"$oid": "666cbc4240af7b375e352e8c"
},
"lastVisit": {
"$date": "2024-06-14T21:55:14.814Z"
},
"date": {
"$date": "2024-06-14T21:55:14.814Z"
},
"__v": 0
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @seantokuzo - Nice to see the site has so many active users! While Testy McTesterson seems like a huge asset to the team, can we add a few teammates for them? Specifically, let's add [email protected], [email protected], and jaime@ codehammers.com. They're all great friends so don't mind sharing the same "ilovetesting" password.

Copy link
Contributor

@brok3turtl3 brok3turtl3 left a comment

Choose a reason for hiding this comment

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

Hey @seantokuzo - Solid workaround to display stock images in dev mode! The user is still able to attempt an upload of a new image in EditProfile. This ends up breaking the display and we also get some S3 connection errors in the terminal as expected with fake credentials.
Screenshot 2024-06-19 at 6 44 29 AM
Screenshot 2024-06-19 at 6 51 06 AM

@brok3turtl3 brok3turtl3 merged commit 4d49c42 into dev Jun 21, 2024
1 check passed
@brok3turtl3 brok3turtl3 deleted the CHE-193/subtask/Create-and-Seed-Mongo-Container-for-Dev branch June 21, 2024 23:10
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.

4 participants