How to Create & Setup Dokku Applications & Databases

How to Create & Setup Dokku Applications & Databases

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.

Freddie Freddie 4 years, 10 months ago 0
Login to Comment
No comments have been posted yet, be the first one to comment.
10 Ways to Manage Environment Variables with Dokku Config Commands
10 Ways to Manage Environment Variables with Dokku Config Commands
Dokku is an awesome open-soure project that makes it really simple to setup and manage your own docker-powered PaaS (Platform-as-a-Service). If you're a solo developer or working in a small team with a low budget, Dokku is godsend. Most applications requires some sort configuration to...
How to Install & Setup Redis for Dokku
How to Install & Setup Redis for Dokku
Redis is a free and open-source in-memory data store which can be used as cache or in same cases even a database. Redis is super simple to install if you manage your applications with your own Dokku PaaS (Platform as a Service). In today's tutorial I will show you how we can install a...
Setup SSL Certificates & Serve your Applications over HTTPS for Free with Dokku & Let's Encrypt
Setup SSL Certificates & Serve your Applications over HTTPS for Free with Dokku & Let's Encrypt
In this tutorial we are going to take a look at how we can setup free SSL certificates for our Dokku powered applications with Let's Encrypt. Let's Encrypt is a non-profit organization that provides TLS (Transport Layer Security) encryption at no charge. Their goal is to make the web ...