This tutorial assumes you already have Dokku installed on Digital Ocean, and already have an app up and running.
dokku plugin:install https://github.com/dokku/dokku-mongo.git mongo
- Is plugin installed?
- Create a database:
dokku mongo:create budgetdb
- Get connection info on db:
dokku mongo:info budgetdb
- Connect db to an app called budget:
dokku mongo:link budgetdb budget
- That will restart the container, and also create a new var called MONGOURL. Get MONGOURL value here:
dokku config budget
- Add that URL and ENVVAR to your Node app locally, also making it the main ENVVAR you’re using.
- Commit and push changes to your dokku remote.
- You should now be using that new DB. Double-check that you’re connected:
dokku logs budget -t
- If your previous Mongo URL was through mLab, connecting to it via localhost:4000/graphql was easy. You can’t do that via dokku/mongo. (It’s pretty locked down, but maybe there’s a way).
- However, if you connect via a localhost React app, it hits the DB just fine.
One local solution
- Using an app, like Robo3T seems to solve the issue.
- But first, you need to expose some ports to the outside. Do this by entering
dokku mongo:expose budgetdb
- This will return some valid ports to try.
- Here are the two Robo3T screens: