Using Dokku with AWS Opsworks

OpsWorks is a great service from Amazon AWS, giving you easy management of AWS resources. However, one big problem of it is the lack of Zero Downtime Deployments which is a major set back when you are working with live production apps.

With Dokku you can turn OpsWorks into what it should always have been. Easy server management with Zero Downtime Deployments.

In this post I will be showing you how to setup you OpsWorks stack to install Dokku and all its dependencies, configure Dokku with a domain, app environment and app ssl support.

Stack Settings

Activate custom Chef cookbooks, you can use as git repository or fork your own. This contains all cookbooks necessary to install Dokku, deploy your app on intance startup and and manage future deployments.

Now you can use the following json to configure your app setup.

I have also included Newrelic on the cookbooks for server monitoring.

Custom Chef JSON
  "nginx": {
    "version": "1.4.4-4~precise0"
  "newrelic": {
    "server_monitoring": {
      "license": "YOUR_NEWRELIC_LICENSE"
  "deploy": {
    "<APP NAME>": {
      "auto_npm_install_on_deploy": false
  "dokku": {
      "git_revision": "master",
    "ssh_keys": {
      "dokku": "YOUR_SSH_KEY",
      "deploy": "ANOTHER_SSH_KEY"
    "domain": "SOMETHING.COM",
    "apps": {
      "<APP NAME>": {
        "env": {
          "NODE_ENV": "production"

APP_NAME should be the same name you give to you OpsWorks app. SOMETHING.COM should be the domain name to be used for Dokku.

The dokku ssh_key user must be deploy as it is the user name OpsWorsks uses during deployments.

(for now you have to change Dokku git_revision to master to make it possible to confugure the app before Dokku initializes it #11)

Layer Settings

custom recipes

Now set the necessary Chef recipes for your layer. Setup takes newrelic and dokku::bootstrap, deploy takes dokku_deploy.

(you don't need newrelic for dokku to work)

App Settings

Finaly, you just need to setup your app. Here you need to set a domain name to be used for your app (your app name for Dokku).
You can also enable SSL and provide the certificates to be included on your dokku app and copied to /home/dokku/:domain name/ssl/ during deployment.

Now you can start planning your server stack and reach Horizontal Scalability and High Availability with ease and Zero Downtime Deployments.

Just use OpsWorks deployment system to push new releases.

Update 1: Check out how to Use Grunt to trigger OpsWorks deployment.