dokku-mongodb-plugin icon indicating copy to clipboard operation
dokku-mongodb-plugin copied to clipboard

Why can't a database be linked to multiple apps. Just wondering if there's a problem with that

Open osiloke opened this issue 11 years ago • 7 comments
trafficstars

I was just about to modify the plugin to accept an extra argument to specify what database should be linked to an app. This is useful if two apps share the same database. Something like

dokku mongodb:link app1 database_app

In my case, i'm using mongodb as a message queue, so multiple apps need to communicate with the same database.

osiloke avatar Mar 02 '14 14:03 osiloke

Thanks, This is a use case I had not thought of but it makes sense to be supported. I will try to check out your solution later today.

jeffutter avatar Mar 02 '14 16:03 jeffutter

Please note there are a few bugs in this commit which i just rectified. I just picked up on how dokku plugins work today and i did not edit the pre-release file. I have updated the code to store passwords in either of the following files

/home/dokku/.mongodb/pass_$APP #For backwards compatibility or /home/dokku/.mongodb/pass_$APP_$DATABASE

Please look at my fork instead of this, i still need to implement namespaces for each DB so you could have DATABASE_MONGO_URL and DATABASE2_MONGO_URL. For now, it works enough for me to use it in my project for now.

osiloke avatar Mar 02 '14 16:03 osiloke

Hello,

What the status of this? Is it supported yet?

metasansana avatar Sep 20 '14 15:09 metasansana

You can do it by hand. I have three apps pointing to the same database. You just need to add manually a new user for (examples) yoursecondapplication with rights to access yourfirstapplication and then create that link just moving some files:

cd /home/dokku/.mongodb
mv pass_yoursecondapplication pass_yoursecondapplication_yourfirstapplication

You'll need to either generate a new password or use the same password for both apps:

echo pass_yourfirstapplication > pass_yoursecondapplication_yourfirstapplication

These are the steps if I recall correctly.

ignlg avatar Sep 22 '14 07:09 ignlg

@metasansana I implemented this behavior in my fork and it works. It seems to have been merged. I'll check this out later today.

@ignlg Yes, that is an alternative but i would really like everything to be automated. It eases deployment

osiloke avatar Sep 22 '14 21:09 osiloke

What is the status of this?

@ignlg

I tried to follow your instructions but with no luck. I'm getting the following error

 Connection fails:  { [MongoError: auth failed] name: 'MongoError', ok: 0, errmsg: 'auth failed', code: 18 }
 It will be retried for the next request.

Do I need to create two apps i.e

dokku mongodb:create app
dokku mongodb:create admin

And then cd /home/dokku/.mongodb mv pass_app pass_app_admin

and then copy the password from pass_app to pass_app_admin

and what about the pass_admin file that is creates after dokku mongodb:create admin?

As you can see I'm confused with this. Is it possible to show an example?

Cheers

ppoliani avatar Jan 12 '15 21:01 ppoliani

@ppoliani

What worked for me was:

Creating a new DB user on an existing DB, for a new app

dokku mongodb:create NEWAPP EXISTINGDB

and linking the new app to the existing DB

dokku mongodb:link NEWAPP EXISTINGDB

dantaeyoung avatar Feb 19 '15 03:02 dantaeyoung