2017-01-29

Deploy your code on DreamHost cloud servers using Dokku, a small Platform As A Service implementation built on Docker. With Dokku running on your instance, you can push code directly from your local machine running git and see it running on a production server. This tiny PaaS implements Heroku’s buildpack specification allowing to run software written in PHP, Golang, NodeJS, Python, and Ruby (including Ruby on Rails). We love it at DreamHost because what’s not to love in a “Docker-powered mini-Heroku in around 200 lines of Bash”?

This tutorial will show you how to install Dokku in one step on a single DreamHost Cloud server running Ubuntu 14.04LTS, using a cloud-init script.



Image courtesy VGB Studios on Flickr

Create a new server

The first step: decide the full domain name for the new server so that Dokku can work at its best. For this tutorial, we’ll use apps.example.com.

With the domain name set, we can start a new DreamHost Cloud server using the openstack command line client, for example. Download the openrc file and the cloud-init script and run the commands:

It’s also possible to use the web UI, feeding the content of dokku cloud-init script in the Post-Creation tab as Customization Script Source.



The cloud-init script simply adds the APT repositories for Docker and Dokku, the respective PGP keys. Then it installs Dokku from the official packages, setting the values of some important variables like the full qualified domain name of the new server, apps.example.com in this case.

In 30 seconds the server boots: get its IP address and create DNS records for the domain. You’ll need to register two A records: one for apps.example.com, and a wildcard record *.apps.example.com—both pointing to the new instance’s IP address.

Now it’s time to push Heroku-like apps to your shiny new PaaS. Unless you already have one in mind, let’s use a simple node.js app, like this Workout Calendar Generator. Log in to the new server, apps.example.com, and prepare the Dokku environment:

On your local machine clone the repository, add a remote to the DreamCompute server and push the code:

If all went well and the DNS records propagated correctly, you should be able to see the Calendar Workout app running at the domain name you used (i.e. http://workout.apps.example.com).

Dokku combined with DreamHost cloud servers makes for a great little tool to quickly iterate and experiment with running code with very little overhead. We hope this has helped you!

Have questions, or want to start a conversation about this? Leave a comment below, or feel free to discuss here!

The post How To Run Dokku Tiny PaaS on DreamHost Cloud appeared first on DreamHost.blog.

Show more