How to setup Dokku on VPS | Deploy your first app using Dokku.

Dokku is a self-hosted version of Heroku. This article is a small guide to how you can set up Dokku on your VPS and we'll be hosting a Strapi app using Dokku on our VPS.

Category:

DevOps

How to setup Dokku on VPS | Deploy your first app using Dokku.

Harsh Vardhan

Sun Jan 31 2021・4 min read

WTF is Dokku? Isn't Docker misspelled?

No, no dokku is different from Docker though it runs on docker only 😁. Dokku is an extensible, open-source Platform-as-a-Service that can run on any server you choose to go with. Dokku is a self-hosted version of Heroku (a cloud application hosting platform). Powered by Docker, Dokku can help you build and manage your application lifecycle in the cloud. Dokku is an extensible, open-source Platform-as-a-Service that can run on any server you choose to go with. Dokku is a self-hosted version of Heroku (a cloud application hosting platform). Powered by Docker, Dokku can help you build and manage your application lifecycle in the cloud.

This article is a small guide to how you can setup dokku on your VPS and we'll be hosting a Strapi app using dokku on our VPS.

Let's start.

Now it's time to fire up your terminal 🌚.

Type the following command to update all of your repos and packages on your Linux VPS.

sudo apt-get update && sudo apt-get upgrade

Now, if that's done we have to install dokku using a bootstrap bash file provided by Dokku boys only. Don't panic just run the following commands.

wget https://raw.githubusercontent.com/dokku/dokku/v0.23.0/bootstrap.sh
 sudo DOKKU_TAG=v0.23.0 bash bootstrap.sh

Now, just hit your VPS IP address in your browser to complete dokku server setup.

https://cdn.auth0.com/blog/vue-dokku:setup.png

Here, in this form you will be asked for a public ssh key needed to login into this dokku server ( pushing your app code to dokku remotely) just the way you do it on git ( using git credentials ). You can use ssh keys on your local machine just by typing the following commands.

cd ~/.ssh && ls 
# most probably you already have ssh keys with the name somewhat like "id_rsa" and "id_rsa.pub". In case you don't have them don't worry guys.

# Just type 
ssh-keygen #this will generate ssh keys

Now copy the content in the "id_rsa.pub" or ____.pub file and paste it into the Dokku form asking for public ssh key.

If that's ✅.

Leave everything as it is (it doesn't even matter). We can always change it later on 🌚😅.

Now hit Finish setup button/CTA and boom 💥.

It's time to test our Dokku server.

Let's create a dokku app.

dokku
# this will list all dokku commands.
dokku apps: help
# to ask dokku for help related to the dokku apps command.
dokku apps:create ${your_appname}
# this is to create a new dokku app don't forget to replace ${your_appname} with your app name.

Now if that's done let's move to our local machine to test our Dokku server.

Open your code folder or repo you wanna push to dokku server remotely and also fire up your terminal ( cause I hate GUI for everything ).
Here, we will be adding repo remote to our dokku server.

git remote add dokku dokku@yourip:yourappname
git push dokku master
# isn't it the same as git push origin master?

Replace your IP with your VPS IP address and your app name with your Dokku app name.

Dokku automatically identifies your app ( node, py, PHP app).

Dokku will start its magic ✨ wait for it to complete doing that ✅.

If that's done just hit

http://yourip:<port running your app>/
if ( app. works )
{
 console.log("Cool ✅✨");
} else if(!app.works){
console.error("Oops something went wrong");
}

Let's debug 😁.

dokku domains:report
# to get domains configuration of your Dokku server
dokku domains:clear-global
dokku domains:clear <yourappname>
# this will clear all of the app vhosts and global vhost domains.

Now, refresh your app webpage ✅✅✨✨.

I hope it works 😅

Video tutorial

How to setup Dokku on VPS | Deploying our first app using dokku | DevOps

Conclusion

Dokku is cool right ✅✨. Now, you can show off your magical powers 💥💥.