docker-flask-mongodb-example icon indicating copy to clipboard operation
docker-flask-mongodb-example copied to clipboard

Manage mongo, and mqtt password through docker secrets

Open danionescu0 opened this issue 3 years ago • 5 comments

danionescu0 avatar Jan 31 '21 16:01 danionescu0

Hi. I see that you have set up docker secrets for MQTT, Is it the same that has to be done for mongo as well?

neelabalan avatar Feb 28 '21 06:02 neelabalan

Weell there are a few steps:

  1. modify docker-compose Mongodb service to work with username and password. You can test it's ok by starting the service and connect to it with username and password from mongo shell
  2. Add MongoDb secrets in secrets section
  3. Modify all docker-compose services that use MongoDb and add the secrets there
  4. Modify all python services to support connection with MongoDb credentials. I would make a function in utils.py that would handle connetion to eliminate duplicate code
  5. Run all tests to see if things are not broken

I've got stuck in step 1, i can't remember why..could not set MongoDb username and password.

You can start here: https://hub.docker.com/_/mongo theoretically it should be simple :)

mongo: image: mongo restart: always environment: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: example

danionescu0 avatar Feb 28 '21 08:02 danionescu0

Got it. This information is good enough for me to get started. I am also working on #20 and thinking of using pytest for it.

neelabalan avatar Feb 28 '21 09:02 neelabalan

Great, keep me updated. If i can help you with anything ask me and we'll discuss it here. Thanks , great work !

danionescu0 avatar Feb 28 '21 09:02 danionescu0

Happy to work with you!

neelabalan avatar Feb 28 '21 09:02 neelabalan