DIY: How to build own PaaS by yourself(Self hosted heroku architecture) on Ubuntu

Selvaganesh
3 min readDec 6, 2017

If you are person who uses heroku frequently you must thought of creating your own Platform as a Service(PaaS).

Here we will use dokku as PaaS and VM as Ubuntu

What is dokku?
Dokku is a Platform as a Service solution that enables you to quickly deploy and configure an application to a production environment on a separate server.

Installation:

# install docker
$ wget -nv -O - https://get.docker.com/ | sh
# setup dokku apt repository
$ wget -nv -O - https://packagecloud.io/gpg.key | apt-key add -
$ export SOURCE="https://packagecloud.io/dokku/dokku/ubuntu/"
$ echo "deb $SOURCE trusty main" | tee /etc/apt/sources.list.d/dokku.list
$ apt-get update
# install dokku
$ apt-get install dokku
$ dokku plugin:install-dependencies --core # run with root!
# go to your server's IP and follow the web installer

once installed check by

root@ubuntu:/home/bacon# dokku version
0.10.5

while installing if you faced issue like below just refer this link

stop session and continue by typing below command

sudo docker build -t gliderlabs/herokuish /var/lib/herokuish

If you’re using Ubuntu 14.04, make sure your package manager is configured to install a sufficiently recent version of nginx, otherwise, the installation may fail due to “unmet dependencies” relating nginx.

Next step,setting SSH Key , Open any browser of choice and navigate to the host’s IP address and configure Dokku via the web admin.

Next deploy first application,make sure that SSH access to github must be enabled on this host

git clone git@github.com:heroku/node-js-sample.git

Now on Dokku host, You will need to ssh onto the host to run this command.

dokku apps:create node-js-sample

Now you can deploy the node-js-sample app to your Dokku server. All you have to do is add a remote to name the app. Applications are created on-the-fly on the Dokku server.

cd node-js-sample
git remote add dokku dokku@<my-dokku-hostname>:node-js-sample
git push dokku master

After pushing you can see below logs

Counting objects: 231, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (162/162), done.
Writing objects: 100% (231/231), 36.96 KiB | 0 bytes/s, done.
Total 231 (delta 93), reused 147 (delta 53)
-----> Cleaning up...
-----> Building node-js-sample from herokuish...
-----> Adding BUILD_ENV to build environment...
-----> Node js app detected
-----> Compiling Nodejs
-----> Using nodeversion: node-6.11
-----> Installing dependencies using 1.9.7

...

=====> Application deployed:
http://<your-host-name>

If you go to the URL that is given, you should be able to see the sample application that deployed.

If you ever need to remove an application that you have deployed, you can do so by issuing this command on the Dokku server

dooku delete app_name

Conclusion

At this point, you should have your first Node.js application up and running on your Dokku server. Dokku is under heavy development, and undergoes changes from one release to the next. We recommend that you regularly check the Dokku page on Github if you plan on deploying production application.

If you like this article share and clap 👏 👏. Thanks!

--

--