How to Install & Setup Dokku on DigitalOcean

DevOps DevOps
DigitalOcean DigitalOcean
Docker Docker
Dokku Dokku
PaaS PaaS

Dokku is a fantastic free and open-source project for creating your very own docker-powered PaaS (Platform as a Service) that helps you build and manage the lifecycle of your applications. You can think of it as your own self-hosted Heroku, for a fraction of the cost. 

Dokku can be installed on any hardware and makes it super easy to manage your server. Creating containers for each app is a breeze and can be done via Dokku commands in the terminal. Redirecting and SSL certificates are covered too, Dokku let's you create free SSL certificates with let's encrypt that are auto renewed just before they expire.

Once your up and running with your host, you can use Git to push your application to the server. Each time you make an updated to the application and make a new push, your container environment is torn down, and recreated once again according to your configuration. Dokku also support zero-down-time deploys, as it can keep your old environment alive until the new one is fully built.

In this tutorial I will show you how we can install and setup Dokku on a DigitalOcean VPS.

1. Point Your Domain to DigitalOcean's Name Server

Unless you want to host your application or website from an IP address the first thing we always have to do is point our domain to our hosts name servers.

All domain retailers provides documentation tailored to their platform on how to change the name server, it should not be hard to find..

Point your domain to DigitalOcean's name server

  1. ns1.digitalocean.com
  2. ns2.digitalocean.com
  3. ns3.digitalocean.com

2. Create a DigitalOcean Project

Once you have pointed your domain we can go ahead and create a new project from within the DigitalOcean dashboard.

Click "Create Project" in the menu and follow the instructions provided by DigitalOcean 

How to Install & Setup Dokku on DigitalOcean

2. Create a Droplet

When you have created a new project we can go head and create a new droplet. Droplets is the name DigitalOcean call the VPS instances, its just your server.

Luckily the DigitalOcean marketplace provides a pre-configured Ubuntu 18.04 LTS and Dokku 0.17.9. We can use this to save some valuble time, as it requires less server configuration. 

You find it under the marketplace tab, while searching for "dokku"

How to Install & Setup Dokku on DigitalOcean

When you have selected "Dokku 0.17.9 on 18.04" we can go ahead and select a region for our server.

How to Install & Setup Dokku on DigitalOcean

Once you have selected a region suited for you we can go ahead and select an SSH key that we want to associate with our new server. We choose to authenticate via SSH keys as it is generally much more secure that using a one-time password.

I won't cover how to create an SSH key for your computer in this tutorial, nor will I show you how to add it to DigitalOcean. There should be plenty of tutorials out there, use a search engine of your choice :D

How to Install & Setup Dokku on DigitalOcean

3. SSH into your newly created droplet

Once you droplet has booted up we can go ahead and open our terminal and SSH into the newly created droplet.

ssh root@123.456.789.101

You will be asked to enter the password of the SSH key you use. If your athentication is successful you will be greeted with the following prompt.

********************************************************************************

Welcome to DigitalOcean's One-Click Dokku Droplet.
To keep this Droplet secure, the UFW firewall is enabled.
All ports are BLOCKED except 22 (SSH), 80 (HTTP), 443 (HTTPS),
2375 (Docker) and 2376 (Docker).

In a web browser, you can view:
 * The Dokku One-Click Quickstart guide: http://do.co/dokku1804#start
 * Your Dokku setup page: http://123.456.789.101

For help and more information, visit http://do.co/dokku1804

********************************************************************************
To delete this message of the day: rm -rf /etc/update-motd.d/99-one-click

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

4. Update Dokku

Before we start configuring our Dokku setup it's wise to update to the latest version of Dokku.

We can install the latest version with wget.

wget https://raw.githubusercontent.com/dokku/dokku/v0.20.2/bootstrap.sh

sudo DOKKU_TAG=v0.20.2 bash bootstrap.sh

5. Setup Dokku

When the update is done, we can go ahead and setup Dokku by navigating to our IP address in the browser (http://123.456.789.101).

Here you will be greeted with Dokku setup page. Verify that the SSH key is correct and add your domain name and click the checkbox to use virtualhost naming for apps.

How to Install & Setup Dokku on DigitalOcean

If you select to use virtualhost naming for apps your applications will be available at http://appname.yourdomain.com and you can redirect individual apps to specific domains later. Just because you choose virtualhost naming you don't have to server your final application from the "appname" subdomain.

That's basically all there is to it, we have now installed Dokku on DigitalOcean and are now ready to start serving our dokker-powered containerized applications.

Hope you enjoyed the tutorials, in the next part of this series I will cover how we can setup individual apps, install heroku-buildpacks, setup redirects and SSL certificates.

Did You Enjoy the Tutorial?

Consider sending some love to Freddie the creator.

Comments (0)

You need to be logged in to comment..

Topics Mentioned in this Tutorial

DevOps
6
0
24
DevOps stands for Development Operations and is a set of practices used to improve software development and information-technology operations. Part of the DevOps responsibility is to setup servers, integrate continuous integration and continuous deployment (CI/CD) to maintain and improve the development life cycle....
DigitalOcean
2
0
1
DigitalOcean is cloud service provider that is popular among developers. DigitalOcean offers droplets (VPS instances) for an affordable price, with the ability to scale at demand. ...
Docker
2
0
15
Docker is set of PaaS products that use OS-level virtualisation to deliver containers that can be used by developers to isolate and automate their deployment and build process of their applications. Docker's products range from open source to closed source enterprise solutions....
Dokku
7
0
0
With Dokku web developers can build their own PaaS (Platform-as-a-Service) with help of Docker and open sourced Heroku build packs. Dokku Installs on any hardware and drastically lowers your cost as Dokku is both free and open source. The dokku setup process is extremly simple and only takes a matter of minutes to complete. Once Dokku is installed and your PaaS is ready for use you can push your local development project using Git. Which builds your applicaion using Heroku buildpacks that runs in isolated Docker containers. As a result, you can run your own PaaS on the cloud provider of your c...
PaaS
4
0
0
PaaS stands for Platform-as-a-Service is a complete development and deployment environment in the cloud. With a PaaS you developers can deliver anything form simple cloud app to sophisticated enterprise applications. A PaaS toolset includes development tools, database management and business analytics. It also includes all of the features included in an IaaS (Infrastructure-as-a-Service) servers and storage, networking security and data center.   ...