Note: Dokuen is no longer supported.
Dokuen is a "personal app platform". It's the same idea as all of these PaaS and IaaS services out there, except you host it on your own machine. Currently, Dokuen supports Mac and Ubuntu. Here is an article that explains my motivations.
gem install dokuen
Install nginx using homebrew or your distro's package manager:
$ brew install nginx
Create a git
user and install gitolite according to package directions. You'll be making changes to the config later, but for now you should be able to create a new repository and push to it.
Run this:
$ sudo mkdir -p /usr/local/var/dokuen
$ cd /usr/local/var/dokuen
$ sudo dokuen setup .
This will ask you a few questions, set up a few directories, and install a few useful commands. It'll also show you some things you need to do. Crucially, you'll need to modify your gitolite config and install it.
$ ssh git@<your_host> dokuen create --application=<name>
git@<your_host>:<name>.git
$ git remote add dokuen git@<your_host>:<name>.git
$ ssh git@<your_host> dokuen config_set -V BUILDPACK_URL="https://github.com/heroku/heroku-buildpack-ruby.git" DOKUEN_SCALE="web=1" --application=<name>
$ git push dokuen master
<deploy transcript>
$ open http://<your_host>:12345/
create
config_set <key>=<value> ...
config_delete <key> ...
scale <type>=<num>...
buildpacks
install_buildpack <url>
remove_buildpack <name>
run_command <command>
shutdown
restart
I have my home router set up to forward ports 80 and 443 to my mac mini, and I have a dynamic DNS system set up with a wildcard CNAME Unfortunately this setup is hard to automate so Dokuen doesn't manage any of it for you.
What it does do is set up Nginx server configs for you that you can choose to use. If you want to use them, put this at the bottom of the http
section of nginx.conf
:
include /usr/local/var/dokuen/nginx/*.conf;
Then, force a restart of your app:
$ ssh git@<your_host> dokuen scale web=0 --application=<name>
$ ssh git@<your_host> dokuen scale web=1 --application=<name>
When you run ssh git@<your_host> dokuen create --application=foo
, Dokuen creates a few directories in it's install directory, setting things up for app deployments. In particular, it creates this structure:
foo/
releases/ # timestamped code pushes
env/ # environment variables. FILENAME => file contents
logs/ # log files, one per process
build/ # cache directory for build side-effects like gems
When you run git push dokuen master
, the following series of events happens:
pre-receive
hook, which invokes /path/to/dokuen/install/bin/dokuen
, which is a wrapper around dokuen with the correct config file setgit archive <git repo> <sha1 of new master branch> > <tmpdir>
mason
on the tmpdir, building the application into a timestamped subdirectory of releases
current
that points at the new timestamped directoryprevious
that points at the previous value of current
dokuen scale
When Dokuen "spins up" a process, it forks the main process, creates a Dokuen::Wrapper
instance and calls run!
on it. The wrapper's job is to immediately daemonize and run the command line in the Procfile
for the given named process, capture logging info, restarting the process if it dies, and forwarding signals to it as appropriate. It writes it's own pid as well as the port it was given at fork-time into a pidfile at current/.dokuen/dokuen.<appname>.<process_name>.<index>.pid
.
Unfortunately the stock Heroku buildpacks install a vendored node.js compiled for the Heroku platform, which happens to be linux. This doesn't work for Mac, which means you have to use a slightly patched version. This one works with a homebrew-installed node.js: https://github.com/peterkeen/heroku-buildpack-ruby
MIT
Fork and send me a pull request. If you'd like to talk about Dokuen there's #dokuen
on irc.freenode.net
, as well as a mailing list.