progrium/dokku — pull request #166 by Kloadut (2013-08-10 18:37:25+00:00)
Title: PostgreSQL plugin

PostgreSQL plugin
---------------------------
I developed a PostgreSQL plugin for dokku. I am submitting a pull-request but I guess it should stay as a "third-party" plugin.

You can see the usage at https://github.com/Kloadut/dokku-pg-plugin
```
$ ssh dokku@server pg:create foo
-----> PostgreSQL container created: pg/foo

Host: 172.16.0.104
User: 'root'
Password: 'RDSBYlUrOYMtndKb'
Database: 'db'
Public port: 49187

$ git remote add dokku git@server:foo
$ git push dokku master
Counting objects: 155, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (70/70), done.
Writing objects: 100% (155/155), 22.44 KiB | 0 bytes/s, done.
Total 155 (delta 92), reused 131 (delta 80)
remote: -----> Building foo ...
remote: Ruby/Rack app detected
remote: -----> Using Ruby version: ruby-2.0.0

... blah blah blah ...

remote: -----> Deploying foo ...
remote:
remote: -----> App foo linked to pg/foo database
remote: DATABASE_URL=postgres://root:RDSBYlUrOYMtndKb@172.16.0.104/db
remote:
remote: -----> Deploy complete!
remote: -----> Cleaning up ...
remote: -----> Cleanup complete!
remote: =====> Application deployed:
remote: http://foo.server
```

Specifications
--------------------
* It builds a ubuntu quantal image with the following Dockerfiles https://github.com/Kloadut/dokku-pg-dockerfiles
* Only postgresql-9.1 and postgresql-contrib-9.1 are installed on the container
* It creates a container per DB, user is "root", database is "db" and password is generated
* It does **not** create database automatically, but it will look forward to see if a database is "linkable" (a.k.a with the same name)
* It uses the DATABASE_URL environment variable, saved in /home/git/myapp/ENV. See https://devcenter.heroku.com/articles/heroku-postgresql#connecting-in-ruby

I will fork this plugin to do almost exactly the same with MariaDB.

**Note:** On my server it remains impacted by this bug https://github.com/progrium/pluginhook/issues/3

Enjoy !
Comments are welcome :)