iiirc/iiirc — pull request #143 by banyan (2014-01-05 17:09:15+00:00)
Title: [DONT MERGE] Migration for dokku

@KitaitiMakoto
/cc @shikakun

I tried how [dokku](https://github.com/progrium/dokku) works.
dokku is a tool which use docker and heroku's buildpack and other stuff.
here's workaround with this branch:

```
DEV banyan ☁ git push iiirc migration-for-dokku:master
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 291 bytes | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
-----> Cleaning up ...
-----> Building dev ...
remote: Note: checking out '685cd38de389211ed1bf853115ccc2e35427bac4'.
remote:
remote: You are in 'detached HEAD' state. You can look around, make experimental
remote: changes and commit them, and you can discard any commits you make in this
remote: state without impacting any branches by performing another checkout.
remote:
remote: If you want to create a new branch to retain commits you create, you may
remote: do so (now or later) by using -b with the checkout command again. Example:
remote:
remote: git checkout -b new_branch_name
remote:
remote: HEAD is now at 685cd38... Set 2.1.0
Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.1.0
-----> Installing dependencies using Bundler version 1.3.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Using rake (10.1.0)
...
Using uglifier (2.3.3)
Using verification (1.0.3) from git://github.com/sikachu/verification.git (at master)
verification at /build/app/vendor/bundle/ruby/2.1.0/bundler/gems/verification-5bb2ffc2c057 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
duplicate dependency on activesupport (>= 0, development), (< 5.0, >= 3.0.0) use:
add_runtime_dependency 'activesupport', '>= 0', '< 5.0, >= 3.0.0'
Your bundle is complete! It was installed into ./vendor/bundle
Bundle completed (0.58s)
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Asset precompilation completed (2.66s)
Cleaning assets
-----> Discovering process types
Default process types for Ruby -> rake, console, web, worker
-----> Releasing dev ...
-----> Deploying dev ...
=====> Application deployed:
http://dev.iiirc.mi.nu

To dokku@iiirc.mi.nu:dev
9eb05c3..685cd38 migration-for-dokku -> master
```

And It worked. (Though I add `/etc/hosts`)
But, yes, we have pros and cons to be discussed.

pros:
* it's interesting to know dokku and docker. There are lots of [plugins](https://github.com/progrium/dokku/wiki/Plugins) and ecosystem (such as heroku's buildpack) works.
* deploy is really easy, just only `git push`.
* easy to create staging environment if we want.

cons:
* development is really active, and threre are many of regression. It's not only matter of docker, dokku also has no compatible changes lot.
* docker is still 0.7.0 toward 1.0.0, there must be breaking changes.

### How to treat stateful server

There are 3 PostgreSQL plugins (it's funny) and 1 MySQL plugins.
https://github.com/hughfletcher/dokku-mysql-plugin
But it didn't work as I expected since docker and dokku are changed.
Though I sent some PRs, but this fork works.
https://github.com/banyan/dokku-mysql-plugin

However, Docker is good for stateless server but it's not good for stateful server as mentioned here, http://blog.stanaka.org/entry/2013/12/01/092642
We need to store data outside the container, and backup as well.

And I don't know MySQL container is currently unstable (don't know yet)

```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
14a9681418ac app/dev:latest /bin/bash -c /start 33 minutes ago Up 33 minutes 0.0.0.0:49161->5000/tcp sad_wright
d04182500eeb app/rails4-sample:latest /bin/bash -c /start About an hour ago Up About an hour 0.0.0.0:49155->5000/tcp backstabbing_lumiere
366e54df6717 mysql/dev:latest /usr/sbin/mysqld 2 hours ago Ghost hungry_archimede
```

https://github.com/dotcloud/docker/issues/2419

### Or use docker only?

It seems many people using Docker to deploy an application.
For instance,

* http://meta.discourse.org/t/docker-images-for-discourse/9540
* https://github.com/essa/docker-gitlab

>While Docker solves some problems, it introduces other problems. Building a Docker container is a complete pain.
http://samsaffron.com/archive/2013/11/07/discourse-in-a-docker-container

I saw this comment and it's very interesting point.
The above way are both building container and in my opnion, it's not good this kind of toy application.
It may be good discourse or gitlab or redmine which are not necesarry continuous deployment compared to normal appications.

Dokku solves this matter simply and hackably.

### Conclusion and my idea

1. Use AWS RDS micro instance reserved instance (it's not so expensive 24$ for 1 year.)
2. Use Dokku for only apps and follow dokku and docker changes, if something is wrong, throw it away and just create new Dokku environment since data is persistent by RDS.

Sorry for long comment :sob: And how do you think?