How to Create & Setup Dokku Applications & Databases

DevOps DevOps
Docker Docker
Dokku Dokku
PaaS PaaS

As I have mentioned many of times before, Dokku rocks! Dokku is a free and open-source project that helps you build and manage the lifecycle of your applications. Dokku does is it by leveraging the power of Docker and Heroku Buildpacks.

It's perfect for solo developers or small teams that want to run their own PaaS (Platform as a Service) and save both time and money in the process. I use Dokku myself and found lots of joy in doing so. It helps me focus more on my projects, and less on the server and deployment process.

In the previous tutorial I showed you how you can install Dokku on a DigitalOcean droplet. Today I will follow along in those footsteps and show you how you can setup your applications, install a database and link it to your application.

SSH into your Dokku instance.

ssh root@123.456.789.101

Create application with Dokku's apps:create command.

Once you have authenticated with your server we can go ahead and create our apps with the apps:create dokku command.

dokku apps:create backend
dokku apps:create frontend

Dokku provieds an apps:list command which we can use to verify that all apps was created correctly.

dokku apps:list

If our apps where created sucessfully they should be displayed in the list. 

=====> My Apps
backend
frontend

Setup a Database

In this example we will install and setup a PostgreSQL database with our project. To be able to use PostgreSQL we need to install a dokku plugin. We do it so that we can run the database separate from our app container, as that container will be rebuilt when your push a new version of your application.

Dokku provides a bunch software available as plugins, including MySQL, PostgreSQL, MongoDB, Redis, Let's Encrypt (for SSL certificates) and many more. Here you can find the list of the available plugins.

Dokku itself is actually built out of the very same plugin system. Since Dokku is just a collection of scripts that run apps using the official Heroku Buildpacks, which are open-sourced as well.

Install the Dokku Postgres Plugin

sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git postgres

Create a PostgreSQL database

dokku postgres:create databasename

We can use the postgres:info command to get the nessesary information to configure the database with our application.

dokku postgres:info databasename

Finially we need to link our database with our app container, in this case "backed".

dokku postgres:link databasename backend

In the next tutorial we will take a closer look at how we can use Git and GitLab's pipelines for CI/CD (Continuous Integration/Continuous Deployment). So that we can safely push our code to our Git repository and then onto the server and rebuild the application.

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....
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.   ...