# install docker wget -nv -O - https://get.docker.com/ | sh # setup dokku apt repository -wget -nv -O - https://packagecloud.io/dokku/dokku/gpgkey | apt-key add - +wget -nv -O - https://packagecloud.io/dokku/dokku/gpgkey | sudo apt-key add - export SOURCE="https://packagecloud.io/dokku/dokku/ubuntu/" export OS_ID="$(lsb_release -cs 2>/dev/null || echo "trusty")" echo "utopicvividwilyxenialyakketyzestyartfulbionic" | grep -q "$OS_ID" || OS_ID="trusty" -echo "deb $SOURCE $OS_ID main" | tee /etc/apt/sources.list.d/dokku.list +echo "deb $SOURCE $OS_ID main" | sudo tee /etc/apt/sources.list.d/dokku.list -apt-get update +sudo apt-get update # install dokku -sudo apt-get install dokku +sudo apt-get install dokku -sudo dokku plugin:install-dependencies --core # run with root! +sudo dokku plugin:install-dependencies --core # run with root! # go to your server's IP and follow the web installer
Installing Dokku on Kubuntu
As I was looking for ways to deploy a node & react site for intranet, I was looking for a self-hosted PaaS (Platform as a Service) I can deploy internally.
I was reading thru "Heroku vs self-hosted PaaS", I decided to go with Dokku (even though CapRover looked quite appealing as well) because I don't need to scale up to multiple servers for intranet pages.
My linux skill is lacking so will be using KDE to configure some Dokku features. You don't need Hyper-V to follow but can also use linux (even though Dokku recommends installing it on a VM) or use Linux VM such as KVM or Virtual Box, etc.
Be warned. I am just writing down these steps for me to come back so it might not be an optimal/recommended to follow these steps.
but please don't hesitate to let me know how to improve the flow (especially without using KDE).
Table of Contents
- What we are building
- Install Dokku
- Deploy a Node app to Dokku
- Check the deployed site
- Parting Words
🚀 What we are building
This is basically what everything comes down to; Deploying a site to Dokku and open it outside VM.
Now you know how the result looks like, let's start with creating a VM (virtual machine).
If you already has a VM with a linux on it, you can skip this part.
◼ Download Kubuntu
Go to the Kubuntu download page and download "64-bit" version of " Kubuntu 18.04.3 LTS".
Emphasis on "64-bit" because
Dokku supports "A fresh installation of Ubuntu x64 - Any currently supported release, Debian 8.2 x64 or CentOS 7 x64 (experimental) with the FQDN set " so you'd need 64-bit image.
◼ Create a VM
You can create a VM manually or using a Wizard ("Quick Create") but as it's a prerequisite, let's create it using a Wizard. (At work, I will delegate this task to a ops manager as I am not so familiar with this frankly 😅).
This pops up a modal and select the Kubuntu ISO downloaded from the previous step. (If you are familiar with regular Ubuntu, you don't have to download Kubuntu at all...).
⚠ Make sure to turn off "This Virtual Machine will run Windows (enables secure boot)".
Lastly "Create Virtual Machine" and you are done.
By default the VM name is"New Virtual Machine". (I renamed it to "Kubuntu 18.04 LTS x64 for Dokku" by right clicking on it and choose "rename").
You'd need to start the VM as it's off by default as well.
◼ Install Kubuntu
On connecting to VM, click on "start" to fire up a Kubuntu installation wizard (by default, the VM is in "Off" state as shown in the previous image).
Click on "Installation Kubuntu" to start the process.
Set up the language, keyboard, timezone, etc and the user account (clicking next, next, next...).
It might take a while, so let's go and grab a cup of coffee ☕ and come back...
After installation has finished, restart Kubuntu (not the VM).
Lastly, log into Kubuntu and start a console.
We are all ready to set up Dokku, finally!
🚀 Install Dokku
Let's take a look at the Dokku installation instructions for
apt. (It's a bit more involved than it looks).
|# install docker|
|wget -nv -O - https://get.docker.com/ | sh|
|# setup dokku apt repository|
|wget -nv -O - https://packagecloud.io/dokku/dokku/gpgkey | sudo apt-key add -|
|export OS_ID="$(lsb_release -cs 2>/dev/null || echo "trusty")"|
|echo "utopicvividwilyxenialyakketyzestyartfulbionic" | grep -q "$OS_ID" || OS_ID="trusty"|
|echo "deb $SOURCE $OS_ID main" | sudo tee /etc/apt/sources.list.d/dokku.list|
|sudo apt-get update|
|# install dokku|
|sudo apt-get install dokku|
|sudo dokku plugin:install-dependencies --core # run with root!|
|# go to your server's IP and follow the web installer|
It's slightly different because the need to run some commands as a root using
The instruction is straight-forward (other than using sudo) I will leave out the output.
After you are done with the last instruction,
sudo dokku plugin:install-dependencies --core, you will be greeted with a message whether to enable web-based configuration. Click "yes".
The last part of the instruction,
# go to your server's IP and follow the web installer shows to open a web page to continue the installation.
You can get the current machine's name with
hostname and open the web page on FireFox (installed even with Minimal Installation).
Fire up FireFox and go to
https://<<your host name>.
In my case,
hostname was set up as
https://dokku shows the following set up page.
I am not well-versed with Linux administration so I went and generated one by following Digital Ocean's article, "How to Set Up SSH Keys on Ubuntu 18.04 - Step 1 — Create the RSA Key Pair".
Open the public key (I used `Kate`, which is like "notepad" on Windows) by typing
kate ~/.ssh/id_rsa.pub (".pub" for "public") and copy the public key.
Paste the public key on the web configuration.
Set the host name to the one returned by
hostname command from Konsole.
Make sure to get the correct name with `hostname` or else , you'd have to manually change it later! (or access with an IP).
I will leave the "Use virtualhost naming for apps" turned off as turning it on would use port 80 and use app-name for the host name.
Check out the output when checked off. (leave this off though)
When you click "Finish Setup", you will be directed to "Deploying to Dokku" page.
🚀 Deploy a Node app
"Deploying to Dokku" shows how to deploy a Ruby on Rails app but as I am not familiar with it at all, I will deploy a Node app (an Express server). And this also enables me not having to install postgres and other dependent services, making it simpler to demonstrate the deploy process.
~/src folder (not to pollute the home directly,
~) and clone "node-js-getting-started" repository (repo, hereafter) from GitHub.
git clone https://github.com/heroku/node-js-getting-started.git
You might be wondering, "You are pasting code? You suck". Yes I know. But explaining how to create a Dokku deployable source with Procfile would be better left in another post as this post is titled "Installing Dokku on Kubuntu".
For now, you don't have to install packages as publishing to Dokku will take care of it automatically.
You need to create an application on where Dokku is hosted. (You can do so by SSH'ing to the host or just run it in Konsole within VM).
dokku apps:create node-js-getting-started
You will be asked to enter the root password.
Then a message will be shown that an app has been created successfully.
Dokku is compatible with Heroku and works similiarly. That means the deployment can be done via
So let's add a remote git repo to deploy to.
|# 1️⃣ 2️⃣ 3️⃣ 4️⃣|
|git remote add dokku dokku@dokku:node-js-getting-started|
1️⃣ is the remote name
2️⃣ is the remote username
3️⃣ is the host name the Dokku instance is running on
4️⃣ is the app that you created in the previous step
When you try to deploy the Node app to Dokku by pushing it to remote
dokku repo, you will get a "ssh: connect to host 192.168.22.242 port 22: Connection refused" error.
We need to install SSH server & client as well as opening the port 22 (using ufw, "Uncomplicated Firewall"). Let's push it again while at it.
|# Install Open SSH server & client|
|sudo apt install openssh-server openssh-client|
|# Open port 22 to allow connection|
|sudo ufw allow 22|
|# Deploy the code to Dokku|
|git push dokku master|
When you push for the first time, you will be prompted by SSH client questioning the authenticity of the server. Just press "yes" to continue.
I am not familiar with this concept so had to google and found this reply (it's for bitbucket but the concept applies).
If you are attempting to push the second time, you will be prompted to enter the password you entered when generating the SSH key. The result of deploy looks like following.
|dance2die@dokku:~/node-js-getting-started$ git push dokku master|
|Enter passphrase for key '/home/dance2die/.ssh/id_rsa':|
|Counting objects: 3, done.|
|Delta compression using up to 4 threads.|
|Compressing objects: 100% (2/2), done.|
|Writing objects: 100% (3/3), 291 bytes | 291.00 KiB/s, done.|
|Total 3 (delta 1), reused 0 (delta 0)|
|-----> Cleaning up...|
|-----> Building node-js-getting-started from herokuish...|
|-----> Adding BUILD_ENV to build environment...|
|-----> Node.js app detected|
|-----> Creating runtime environment|
|-----> Installing binaries|
|engines.node (package.json): 10.x|
|engines.npm (package.json): unspecified (use default)|
|Resolving node version 10.x...|
|Downloading and installing node 10.16.3...|
|Using default npm version: 6.9.0|
|-----> Restoring cache|
|-----> Installing dependencies|
|Installing node modules (package.json)|
|added 79 packages from 65 contributors and audited 248 packages in 3.84s|
|found 0 vulnerabilities|
|-----> Pruning devDependencies|
|removed 79 packages and audited 127 packages in 1.386s|
|found 0 vulnerabilities|
|-----> Caching build|
|-----> Build succeeded!|
|-----> Discovering process types|
|Procfile declares types -> web|
|-----> Releasing node-js-getting-started (dokku/node-js-getting-started:latest)...|
|-----> Deploying node-js-getting-started (dokku/node-js-getting-started:latest)...|
|-----> App Procfile file found (/home/dokku/node-js-getting-started/DOKKU_PROCFILE)|
|DOKKU_SCALE declares scale -> web=1|
|-----> Attempting pre-flight checks|
|For more efficient zero downtime deployments, create a file CHECKS.|
|See http://dokku.viewdocs.io/dokku/deployment/zero-downtime-deploys/ for examples|
|CHECKS file not found in container: Running simple container check...|
|-----> Waiting for 10 seconds ...|
|-----> Default container check successful!|
|-----> Running post-deploy|
|-----> VHOST support disabled. Skipping domains setup|
|-----> Creating http nginx.conf|
|-----> Running nginx-pre-reload|
|-----> Renaming containers|
|Found previous container(s) (5e9e0a95731a) named node-js-getting-started.web.1|
|Renaming container (5e9e0a95731a) node-js-getting-started.web.1 to node-js-getting-started.web.1.1569718919|
|Renaming container (bccaa0d7a197) goofy_rhodes to node-js-getting-started.web.1|
|-----> Shutting down old containers in 60 seconds|
|=====> Application deployed:|
|97e6c72..1d859f3 master -> master|
🚀 Check the deployed app
At the bottom of the deployment log, you will see the deployment URL.
I am not sure how to expose VM hostname outside, so browser inside VM uses
https://dokku:PORT to access while outside VM, it is using the IP.
Please let me know if you know of a way to access the VM hostname outside the VM... 🙏
👋 Parting Words
As mentioned in the opening, I wrote this as more of a self-note and is a learning process (for Dokku, VM, Linux, etc.).
There should be many steps that I am doing, either unnecessary, or plain out wrong.
Please let me know how I can improve the process or leave comment on what is just dead right wrong.
Below are resources mentioned in this post.