• This repository has been archived on 16/Oct/2018
  • Stars
    star
    550
  • Rank 80,860 (Top 2 %)
  • Language
    Ruby
  • Created over 12 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A personal PaaS for mac and linux

Dokuen, a Personal App Platform

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.

Requirements

Installation

Step 1

gem install dokuen

Step 2

Install nginx using homebrew or your distro's package manager:

$ brew install nginx

Step 3

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.

Step 4

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.

Creating an App

$ ssh git@<your_host> dokuen create --application=<name>
git@<your_host>:<name>.git

$ git remote add dokuen git@<your_host>:<name>.git

Add some environment variables

$ ssh git@<your_host> dokuen config_set -V BUILDPACK_URL="https://github.com/heroku/heroku-buildpack-ruby.git" DOKUEN_SCALE="web=1" --application=<name>

Deploy

$ git push dokuen master
<deploy transcript>

Check it out!

$ open http://<your_host>:12345/

Available "app" Sub-commands

  • create
  • config_set <key>=<value> ...
  • config_delete <key> ...
  • scale <type>=<num>...
  • buildpacks
  • install_buildpack <url>
  • remove_buildpack <name>
  • run_command <command>
  • shutdown
  • restart

DNS Setup

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>

How it works

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:

  • If the target git repo does not exist, gitolite creates it
  • git runs the pre-receive hook, which invokes /path/to/dokuen/install/bin/dokuen, which is a wrapper around dokuen with the correct config file set
  • runs git archive <git repo> <sha1 of new master branch> > <tmpdir>
  • invokes mason on the tmpdir, building the application into a timestamped subdirectory of releases
  • creates a symlink current that points at the new timestamped directory
  • creates a symlink previous that points at the previous value of current
  • spins up the configured number of processes as set using dokuen scale
  • writes out a new nginx configuration and restarts nginx
  • shuts down the previous processes

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.

Rails

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

License

MIT

Contact and Development

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.

More Repositories

1

ledger-web

A web-based reporting system for the Ledger command line accounting program
Ruby
123
star
2

sites

Simple wiki-based site generator.
Ruby
87
star
3

trading

A toy trading engine that only supports BUY and SELL limit orders
Ruby
86
star
4

calorific

Command-line nutrient tracking tool
Perl
79
star
5

marginalia

Marginalia
CSS
75
star
6

heroku-buildpack-vendorbinaries

A Heroku Buildpack for vendoring binaries into your application
Shell
63
star
7

capistrano-buildpack

Deploy 12-factor applications with Capistrano
Ruby
43
star
8

mmp-builder

Code for building Mastering Modern Payments
Ruby
37
star
9

proclaunch

A pure-perl process management system
Perl
28
star
10

Ledger-Tools-Demo

Tools that I use in association with Ledger
Python
26
star
11

git-hooks

Git hooks I use on my gitolite server
Python
23
star
12

route53_ddns

Route53 DDNS Updater
Ruby
15
star
13

dokuen-scripts

14
star
14

dotfiles

These are my dotfiles
Shell
14
star
15

herokubrew

A binary dependency build system for Heroku
Ruby
13
star
16

tailscale-op-proxy

Ruby
13
star
17

stripe_reporter

Simple reporting tool for Stripe SQLite Export
Ruby
13
star
18

ledger-web-config

My personal Ledger Weg config
Ruby
12
star
19

docker-compose-stack

Use docker-compose and watchtower to self-deploy and auto-update a stack
Shell
7
star
20

speedee

A web-based mail client for notmuch
JavaScript
7
star
21

sequins

Temporal sequences
Ruby
6
star
22

foreman-export-nginx

Export foreman applications to nginx configs.
Ruby
6
star
23

nomic

A game of Nomic
6
star
24

diycdn

Hosting my own CDN for fun and profit
Ruby
5
star
25

page_viewer

View a directory of markdown files as a series of web pages
Ruby
4
star
26

fly-proxy

Dockerfile
4
star
27

aioesphomeserver

Python implementation of ESPHome native API server
Python
4
star
28

homer

Self-contained system for managing home directories
3
star
29

homelab

My homelab configs
HTML
3
star
30

bugsplat.info

Source code for http://bugsplat.info
JavaScript
3
star
31

Phytos

A simple photo gallery rails app
Ruby
3
star
32

ledger-snap

Backup ledger files to tarsnap
Shell
2
star
33

kata

Various code kata projects. Mostly lisp implementations.
Perl
2
star
34

ledger_gen

Generate ledger-cli files
Ruby
2
star
35

baroque

An elegant email client for a more civilized age
JavaScript
2
star
36

rubyquiz

Ruby quiz answers
Ruby
2
star
37

plaid-gateway

Gateway for Plaid transactions
2
star
38

demosite

Code for the sites demosite
2
star
39

marginalia-io

Marginalia Ruby API and command-line client
Ruby
2
star
40

emacs

My emacs config
Emacs Lisp
2
star
41

bbiz-archive

Archive for bbiz slack chat
Ruby
2
star
42

wyse3040setup

Shell
1
star
43

roku-parental-controls

Ruby
1
star
44

moves-backup

Moves Backup
Ruby
1
star
45

macguffin

A stupid usenet client
Go
1
star
46

fax-twimlet

Fax -> Email gateway
Ruby
1
star
47

is-kettleman-still-open.github.com

JavaScript
1
star
48

painkillerjane

A tiny sinatra/datamapper app to track painkiller dosing
Ruby
1
star
49

sequel-reporter

A small opinionated framework for writing reporting applications using Sequel
JavaScript
1
star
50

uploads

A little application for uploading files to a remote server
JavaScript
1
star
51

bugsplat-puppet-conf

standalone puppet config for bugsplat ec2 images
Ruby
1
star
52

calendar-remixer

Scrub, filter, and mix multiple calendars into one iCal feed
Ruby
1
star
53

trimet-iframe

An embeddable iframe for Trimet arrival info
Ruby
1
star
54

ssl-management

How I manage my certificates
1
star
55

feeds

RSS to Email feed reader
Ruby
1
star
56

ledger_tiller_export

Tiller + Ledger + Sorbet
Ruby
1
star