Your Own Mini-Heroku on AWS

Heroku is one of those really great tools to help you get started fast with hosting. They support a variety of stacks and save you blood, sweat and tears when it comes to deploying an app. But what about those times where you need to mess with filesystems or have custom binaries that you want to run? How about just having more control of your servers? Dokku to the rescue! Dokku is a small (just above 100 lines of code) yet very powerful tool based on Docker. Dokku utilizes Docker and Nginx plus some other candy to significantly simplify the process of deploying.

Cheaper, because lets face it; you get tired of waiting for that Heroku dyno to start up

Disadvantages:

Doesn’t scale as easily

Doesn’t necessarily have the guarantee of availability as Heroku (depends on server hosting)

Still pretty fresh (but lots of new features in progress)

For now I think that Dokku is great for development, maybe as a staging server to be used within a company or for hobbyists. It is super fast to set up and allows you and your co-workers/friends to host apps simply. Dokku also saves you the time for setting up web servers and configurations in the case you just want to host your own apps.

Below is a couple of fast steps in order to get started with Dokku on AWS. In this tutorial we will set up a sample Node.js app using Sailsjs. We assume you already have access to AWS.

Once the instance is up and running, we need to allow port 80 for our instance. This can be done under “Security Groups” in the AWS console.

Now that we have the server up and running go ahead and point any top level domain to this instance. The ip of the instance can be found in the AWS console in the description for your instance (Public IP).

Next thing to do is to ssh into your new Ubuntu 13.04 server and install Dokku (which automatically installs all dependencies and sets everything up for you):

At this point we have a server running on AWS, with dokku running on it. We have generated a brand new app using Sailsjs and we have added necessary Procfile to make it run on our server. We now need to add the remote and then deploy:

2 Comments

The Nginx is used a proxy to route basically “route” the apps. Your DNS *.domain.com needs to point to your dokku server. Nginx lies in the front proxying the request to the right application server. Example: User browses to –> app123.domain.com:80 –> Nginx on port 80, realizes it’s a request for app123 –> proxies to localhost:3000 (or whatever port it chose to run this particular app on).

Looking into the source code, it seems Dokku is for Ubuntu or any distro with an apt based package manager. I base that on the way it installs the dependencies (using apt). Not sure how well it would work with any other similar distro, but given the recommendations in the documentation it seems your better off keeping to a specific Ubuntu version (13.04)