CodingGarden / entropychat.app

A discord clone made by the Coding Garden Community.
https://entropychat.app
103 stars 37 forks source link

Fix docker mongo setup #27

Open carlan opened 4 years ago

carlan commented 4 years ago

On first or second stream you were having issues with docker and mongodb. The impression from the stream was the db service was delaying the start up somehow. The issue is also referenced on the docker-compose.yml as a comment.

I'm creating this issue to start a discussion (if required), have a quick look on the setup and also reference it on future PR.

carlan commented 4 years ago

I found some missing bits and pieces here and there.

The main one was the initialization script, when we config the MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD the user is created on the admin database as we are able to see on the logs. However, when we try to create the database configured on the .env file, nothing happens.

To solve this issue I created a simple script to add the users collection as we need to add "something" on the database to create it.

carlan commented 4 years ago

I forgot to mention that If the database has already been created remember to remove the server/docker-data/db directory as everything I've said on previous comment happens only once when the database is being created.

carlan commented 4 years ago

PR updated with the changes requested.

EDIT: I saw you had a bit of hard time understanding/remembering (no offence intended) what's going on. I should have added a comment explaining what I've done. Sorry about that. The solution I've applied for this is rudimentar simple, I believe as you wanted/mentioned on previous stream. On db container I'm exporting the mongo logs in a volume, without it the server api wouldn't have a way to check if the database is ready or not based on the string. On server api container, I'm reading the log from the same volume and waiting for the string before continue.