Deploy database to production with official Dokku plugins

Self-hosted prod deployment with 3 lines of code: Postgres, MySQL, Mongo, Redis, MariaDB, Elastic, Clickhouse, RabbitMQ, Rethink, CouchDB and more

Deploy database to production with official Dokku plugins

I'll give a list of databases that already has Dokku integrations (plugins or addons). It means that you can easily attach them to your Dokku apps and run everything in production using literally 3 bash commands.

What is Dokku

TL;DR: Dokku is a self-hosted Heroku alternative.

Many of devs really like Heroku which automatically deploys the code from Github repo so you don't have to spend time on DevOps stuff. But when your project grows Heroku becomes very-very expensive. Moreover, you have to pay separately for a service and for attached databases.

So here comes Dokku - open-source Heroku clone. It has the same things you liked Heroku for except for GUI (yes, Dokku has a CLI only but there are a plenty free open-source web interfaces on Github). You can easily install Dokku to any machine, e.g. I use Digital Ocean droplets.

What about database add-ons on Heroku

There are two ways to run any service on Heroku (e.g. Mongo, Postgres, MySQL): using official add-ons or run them on a Dyno. First way is more production-friendly, but in this case you would be charged a lot to have something more than a free tier.

The second way is a real DevOps challenge. Hopefully, there are a bunch of Heroku buildpacks out there but there (e.g. for CouchDB). But again: Heroku free tiers are pretty limited so you would need to pay a lot real soon.

So that's why I prefer to rent a Droplet on DigitalOcean, install Dokku and then run anything I want. If I need to scale things up, I just enlarge a droplet using DigitalOcean's website.

How to attach database to Dokku app

Let's assume that you have a Django app and you need to create & attach Postgres database to your Dokku app (you don't want to run Sqlite3 in production).

First of all, you need to install the integration you need (if now installed yet): go to the official integration Github repo and copy-paste the installation script:

sudo dokku plugin:install postgres

Then you need to create the database.

dokku postgres:create my_sexy_database

And then link it to your Dokku app:

dokku postgres:link my_sexy_database my_sexy_dokku_app

In result, your Dokku app will receive a new DATABASE_URL environment variable with a connection string (with host, port, login, password and database name).

If you use Django, you may want to use (old but good) dj_database_url library to automatically config the project when DATABASE_URL .env var is set.
    'default': dj_database_url.config(conn_max_age=600),

Databases with 1-click Dokku add-ons

Here is a list of official Dokku plugins to 11 databases. It means that you can install any of there databases with only 3 lines of code (like I showed above for Postgres).

PostgreSQL, Github 9.1k⭐️*, Dokku plugin

The World's Most Advanced Open Source Relational Database. PostgreSQL features transactions with Atomicity, Consistency, Isolation, Durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures. It is designed to handle a range of workloads, from single machines to data warehouses or Web services with many concurrent users.

MySQL, Github 7.1k⭐️*, Dokku plugin

MySQL is conceivably the most popular and recognizable RDBMS worldwide. Such giants as Facebook, YouTube, Uber, Google, and countless other corporations prefer MySQL for their data storing and management. And they have all the reasons to stick to this RDBMS.

MongoDB, Github 20.6k⭐️, Dokku plugin

MongoDB is a document-oriented NoSQL database used for high volume data storage. Instead of using tables and rows as in the traditional relational databases, MongoDB makes use of collections and documents. Documents consist of key-value pairs which are the basic unit of data in MongoDB. Collections contain sets of documents and function which is the equivalent of relational database tables. MongoDB is a database which came into light around the mid-2000s.

Redis, Github 51.6k⭐️,  Dokku plugin

Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache, and message broker. Redis provides data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs, geospatial indexes, and streams. Redis has built-in replication, Lua scripting, LRU eviction, transactions, and different levels of on-disk persistence, and provides high availability via Redis Sentinel and automatic partitioning with Redis Cluster.

Memcached, Github 11.3k⭐️,  Dokku plugin

Memcached is a high-performance free, open-source cache framework for distributed objects. It is used for accelerating dynamic web applications by loading the database. The websites have huge information they use the Example: Twitter, Youtube, and Wiki, etc. One of the key things you can do to speed up the website properties’ delivery is to have the correct cache arrangements in place.

MariaDB, Github 4k⭐️,  Dokku plugin

The open source relational database. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.

Elasticsearch, Github 57k⭐️,  Dokku plugin

Elasticsearch is a highly scalable open-source full-text search and analytics engine. It allows you to store, search, and analyze big volumes of data quickly and in near real time. It is generally used as the underlying engine/technology that powers applications that have complex search features and requirements. Elasticsearch provides a distributed system on top of Lucene StandardAnalyzer for indexing and automatic type guessing and utilizes a JSON based REST API to refer to Lucene features.

ClickHouse, Github 20.2k⭐️,  Dokku plugin

ClickHouse® is a real column-oriented DBMS with no extra data stored with the values. Among other things, this means that constant-length values must be supported, to avoid storing their length “number” next to the values. For example, a billion UInt8-type values should consume around 1 GB uncompressed, or this strongly affects the CPU use. It is essential to store data compactly (without any “garbage”) even when uncompressed since the speed of decompression (CPU usage) depends mainly on the volume of uncompressed data.

RethinkDB, Github 25.1k ⭐️,  Dokku plugin

RethinkDB is an open-source database that, unlike traditional database systems, stores the information in JSON (JavaScript Object Notation) format. Because of this, it's considered a NoSQL (Not Only SQL) database, such as MongoDB, Cassandra, and CouchDB.

RabbitMQ, Github 8.9k ⭐️, Dokku plugin

Most widely deployed open source message broker. RabbitMQ is an open-source message-broker software that originally implemented the Advanced Message Queuing Protocol (AMQP) and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT), and other protocols.

CouchDB, Github 5.1k ⭐️, Dokku plugin

Seamless multi-master syncing database with an intuitive HTTP/JSON API, designed for reliability. CouchDB supports both horizontal partitioning and replication to create an easily managed solution for balancing both read and write loads during a database deployment. CouchDB features a very durable and reliable storage engine that was built from the ground up for multicloud and multi-database infrastructures.

More databases in Dokku

You can find unofficial plugins on Github - there are a lot of them because people love Dokku!

* - this repo is a Github mirror. That is why there are so few stars.

For all data lovers I've created a spreadsheet with all mentioned databases!

Thanks for reading! Feel free to ask me any question on Twitter