Hello everybody. A bit of a weird question here. I...
# ask-questions
Hello everybody. A bit of a weird question here. I was wondering how I would edit the source code of Growthbook and create a new image of it? Long story short, the way growthbook accepts a MONGODB_URI does not really work for my use case, and I would prefer to edit the source code to accept username, password, and endpoint, and then growthbook builds the URI. I have tried editing the source code and building a new image, but it doesn't seem to work properly and I'm not really sure why. Any help is appreciated. Thanks :)
did you follow the contributing guide?
you could also open a pull request with the changes to support another way of connecting to MongoDB
but I believe the connection string does support user/password
I will look into the contributing guide. As far as I've seen I need to send growthbook a complete MONGODB_URI as an ENV variable. This poses issues when using AWS CDK. I'd like to be able to send the parts that make up the URI, and have growthbook build it. But I will look into the contributing guide and see if I can figure out a solution. Thanks 🙂
I think other people also have wished this. It does seem reasonable for us to support this, so if you do make a PR let me know and we will probably merge it.
I've seen a LOT of folks in Slack complaining about this problem
@helpful-application-7107 was checking with the GB team about any technical issues with this
@elegant-king-24193 This is my proposal based on your suggestion: https://github.com/growthbook/growthbook/compare/main...yepher:growthbook:feature/alt_mongo_credentials
Copy code
let MONGODB_URI = process.env.MONGODB_URI;

  // Check for alternate mongo db environment variables
  if (
    process.env.MONGO_DB_USERNAME &&
    process.env.MONGO_DB_PASSWORD &&
  ) {
    MONGODB_URI = `mongodb://${process.env.MONGO_DB_USERNAME}:${process.env.MONGO_DB_PASSWORD}@${process.env.MONGO_DB_HOSTNAME}/growthbook`;

    // Add extra args if they exist
    if (process.env.MONGO_DB_EXTRA_ARGS) {
      MONGODB_URI += `?${process.env.MONGO_DB_EXTRA_ARGS}`;
So it will still prefer
from env. But if that is not set, then if
are set, then compose the
from the individual values. If
is set in the environment, then also set that as the query string part of the
I think MONGO_DB_EXTRA_ARGS is important because in cases like DocumentDB you need to be able to provide stuff like
Copy code
💯 1
@cuddly-finland-73937 Thanks so much for putting that together. I started a PR and left some comments. If you can address them, then I'd be happy to get this merged into main!
@white-fireman-22476 made some changes based on your comments
Thank you so much for taking the time to do this 😄
Sure... I made a few more comments on the PR. @cuddly-finland-73937.
@white-fireman-22476 added your suggestions
👀 1
I ended up closing that PR and opening my own with a few other changes: https://github.com/growthbook/growthbook/pull/1772. I'll let you know when it lands.
🎉 1
This has landed. You can see the new envs that the mongo uri can be generated from here: https://docs.growthbook.io/self-host/env
❤️ 3