RethinkDB on Heroku

This doc explains the quick and easy way to run RethinkDB as a microservice attached to your Heroku app.

Pre-requisites: you'll need Docker and docker-compose installed on your development machine.

First install the add-on and CLI plugin:

heroku addons:create dockhero
heroku plugins:install dockhero

Now generate dockhero-compose.yml using our repository of examples:

heroku dh:generate rethinkdb

Since we want our Dockhero installation to be secure, let's invent two passwords: one for DB connection, another for Admin UI. When you assign these passwords to Heroku config variables, they become available to both your Heroku app and Dockhero stack:

heroku config:set RETHINKDB_PASSWORD=<db connection password>
heroku config:set RETHINKDB_ADMIN_PASSWORD=<admin UI password>

Now we're ready to launch the stack using docker-compose:

heroku dh:compose up -d

After a few seconds you should be able to open the admin UI in the browser and login with admin:RETHINKDB_ADMIN_PASSWORD credentials

heroku dh:open https

Connecting from Heroku

The address of RethinkDB host is exposed to DOCKHERO_HOST environment variable. Here is a Ruby example which connects to RethinkDB from within a Heroku app using NoBrainer ORM:

NoBrainer.configure do |config|
  config.rethinkdb_urls = ["rethinkdb://admin:#{ENV.fetch('RETHINKDB_PASSWORD')}@#{ENV.fetch('DOCKHERO_HOST')}:28015/<dbname>"]
end

Drawbacks

Dockhero provides a convenient way to quickly get up and running with RethinkDB on Heroku. However this doesn't replace true DBaaS solutions required in production. At the very least you need to take care of backups and security. We recommend the setup above for Staging & Development environments.

results matching ""

    No results matching ""