Cloud Tutorials

How To Run Dokku Tiny PaaS on DreamHost Cloud

Written by Stefano Maffulli

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.

https://c8.staticflickr.com/8/7146/6632839863_286769a89f_b.jpg

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:

$ source openrc.sh
$ openstack server create
--image Ubuntu-16.04
--flavor gp1.semisonic
--security-group default
--key-name $YOUR_SSH_KEYNAME
--user-data dokku-cloudinit.sh
my-dokku-server

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.

images/dokku-customization-script.png

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:

[localhost]$ ssh ubuntu@apps.example.com
[ubuntu@apps.example.com]$ dokku apps:create workout # the name of the app
[ubuntu@apps.example.com]$ exit

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

[localhost]$ git clone git://github.com/clee/p90xcalgen
[localhost]$ git remote add dokku dokku@apps.example.com:workout # the same name used in the dokku command before
[localhost]$ git push dokku master

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!

About the author

Stefano Maffulli

Stefano is the Director of Community at DreamHost.

12 Comments

  • @Dreamhost

    When do you plan to upgrade your use of Ubuntu? You’re currently running v14.x which LTS support ends in just 3 month (April) and it’s also 2 major releases behind.

    It’s scary to see how far behind you are on maintenance.

  • hi Ted, DreamHost Cloud product, DreamCompute (the product that this blog post is referring to) already offers Ubuntu 14.04LTS and 16.04LTS. You’re probably thinking of Ubuntu 12.04, you’re right that the deadline is fast approaching and we’re working toward ensuring all our products are on a more recent LTS release

    • @Dreamhost

      I’m on a VPS and also have another site on a shared server. Both are on Ubuntu 12.

      Do you have an eta on when all services will be upgraded to Ununtu 16?

      I’ve open multiple support tickets as well as support chat and no one in support knows … and even more concerning – no one in supoort is even aware of any upgrade plans.

      Unbuntu 12 is out of support in just 3 months.

      I’m scared.

      • I see why you’d be concerned but rest assured that there are more than just plans to put all our products on latest Ubuntu LTS versions. Also, keep in mind that once an Ubuntu release reaches its end of life, doesn’t mean that all of a sudden nothing will work again and that DreamHost will still support customers, keep their sites safe and running as usual.

        • @Stefano

          Can you give any insight on what “assured that there are more than just plans to put all our products on latest Ubuntu LTS” means?

          Does that imply new features/functionality for existing VPS and Shared hosting customers? If so, what?

          So, any ETA on when this will happen?

          The more transparency, the better

          • The product teams don’t have a deadline set yet so we can’t commit publicly to an ETA. Customers will be notified of new features and eventual disruption as those become known, as usual.

            For things like OS upgrades, we usually don’t issue press releases because the vast majority of customers only care for their sites to be up, not the details about the underlying OS.

            Those who care about the OS use DreamCompute, where they have full control. I would suggest you to look at https://cloud.dreamhost.com if you need to use a specific OS for your applications. The forums https://discussion.dreamhost.com are available to discuss more in-depth your needs.

  • @Stefano

    The problem is, the reason why I pay a *premium* to use VPS (and previously was a Dedicated server customer) over Compute is because I’m paying DreamHost to “manage” my environment for me.

    That’s the whole value prop of VPS/Dedicated – it that it’s a managed environment.

    However … I hardly feel like I’m gaining any value from the premium that I pay for VPS when the OS hasn’t been updated in 5 years.

    See why I have heartburn now.

    • I too am a VPS customer.

      I too question why I am paying a premium for a managed service.

      DreamHost, please update your OS software. It’s painfully dated.

    • I see why you have concerns, and those are legitimate ones. I want to make it clear though that the premium prices for a managed service are exactly because customers don’t have to worry about the underlying OS or package versions. DreamHost staff takes care of those and you shouldn’t worry about that.

      If you need the newest packages you should consider using DreamCompute instead. If you don’t want to manage the server, add a simple management layer on top like ServerPilot. They offer instructions on how to setup management on DreamCompute https://serverpilot.io/community/articles/how-to-create-a-dreamcompute-server-on-dreamhost.html

      • @Stefano

        If you’re suggestion to use DreamCompute + ServerPilot over DH Managed VPS or DH Managed Dedicated … are you implying those offerings (VPS & Dedicated) from DreamHost are dead?

        Why still offer and sell them if you’re not even recommending them?

        • Please, @Victor that’s not what I said nor implied. I simply offered options to customers who expressed concerns, which are the same options I’d offer to a friend.

          DreamHost offers VPS and Dedicated servers, both are fully managed products that will continue to be offered for the foreseeable future. Both those products have a limited amount of flexibility around the choice of operating system version. Some people here expressed their dislike for such limitations.

          DreamHost also offers *unmanaged* virtual servers DreamCompute which allows almost complete freedom of choice of operating system (one could even run Microsoft Windows Server there, for example). But with great flexibility comes the responsibility to maintain a server from scratch.

          Since I *know* that many customers want new Ubuntu or CentOS but don’t want to maintain a server, I suggest as an option to look at Serverpilot if they absolutely need newer OS versions.

          Otherwise, just wait for DreamHost to upgrade VPS and Dedicated: your sites won’t stop working or being supported by DreamHost, even after Canonical stops updating the OS.

          If you have specific needs of software version please state them precisely (what you need and why) to help shape product roadmaps because this conversation at this point has become too generic to be meaningful for our product managers.

  • +1 to Teds concerns about shared/vps/dedicated and lack any type of update on OS and packages in years.