Development to Production in less than 5 minutes

Gaurav Mehla
Sep 19, 2017 · 6 min read


Courtesy from DigitalOcean

One server will run Node.js application, while the other will provide users with access to the application through an Nginx reverse proxy to the application server.

To put our application on server, we will use dokku.

Dokku is a mini-Heroku powered by Docker written in less than 100 lines of Bash. Once it’s set up on a host, you can push Heroku-compatible applications to it via Git. They’ll build using Heroku buildpacks and then run in isolated containers. The end result is your own, single-host version of Heroku.

Dokku makes it easy to deploy and manage web applications on your own server in a way that’s very similar to Heroku. Except on DigitalOcean, it’s faster, cheaper, and you have more control. Now DigitalOcean has a one-click application for creating a Dokku Droplet, making it even easier to have your own private application platform in a matter of minutes.


  • You must have an application which we will soon deploy on server. If you don’t have a NodeJS application yet, you can create one by using express-generator.

⚠️ Just follow these steps and soon you will have a NodeJS application running and ready to deploy.

Spinning up our server

Note : If you haven’t create droplet before, you can follow this basic guide. But its recommended to have a experience with droplets. If you do not have that right now, first go and have one. If you face any kind of problem while creating your first droplet, feel free to ask me; You can have $10 credits in your account on first registration. Click here to get one.

  • Login into your DigitalOcean account and Click on Create.
  • Now click on One-Click Apps and select Dokku.

This is the only major thing which you have to make sure about. After this you can choose whatever setting you want i.e you can choose size, location and SSH keys as per your choice.

Its recommended to use 5$/mo if you want to learn how to deploy application and if you really want to use this server as production, Then please go for 10$/mo.

Then wait for some time until DigitalOcean will make your server ready.

Instead of XX.XXX you will see your IP address here

You will receive a notification soon.

Remember, it will take little time to spin up your server after this notification also. So sit back and please wait, it will take approximately 2–3 more minutes because during this time our server is preparing dokku configurations.

Configuring Dokku

If you used a DigitalOcean SSH key with your Droplet, it should already be filled in for your admin SSH public key. Anybody set up with this key can deploy and manage apps on your Dokku. You can add more later, but this one is for you. If there’s no key in that first box, you’ll have to create a keypair and paste in the public key. Remember, here’s a great article if you forgot how.

⚠️ Change Hostname to your domain name if you have any. You also have to first configure this domain with your DigitalOcean account.

  • Click Finish Setup and you will redirected to dokku documentation. Thats it! Now the only thing we have to do is push our code to this server.

Congratulations!, If you reached here, you are doing very well.👍

🔱 Final Touch

  • A package.json file in the project root. — This is the file which tell dokku that you have a NodeJS application.
  • Your package.json must contains a start script. — Dokku will execute npm start in order to run the app after deployment. Thats why it is must. Click here if you don’t know how to make a npm script.
  • Your application must have at least one commit. — If you are not familiar with git. Click here to learn how to make your first commit.

📕 Read this guide to know more about how to make your NodeJS application ready for deployment ?

If your application has all the things listed above, you are good to proceed.

Now, you have to add dokku remote with your repository. The remote will be something look like as shown below :

⚠️ If you don’t know what Git Remote is ? Click here.

Now fasten your seat belt and get ready to deploy 🚀. Execute the following command :

git push dokku master

⚠️ If you want to push another branch, you have to specify that like this :

git push dokku <your_branch>:master

You must have to push your code to master branch because dokku has hooks on master branch. If you push your code to any other branch, your code will not be live on the server but it will get pushed to dokku.

Below is the output which you will see while dokku is pushing and deploying your application on server.

-----> Running post-deploy
=====> renaming container (56afae26699c) upbeat_jackson to myapp.web.1
=====> no global VHOST set. disabling vhost support
-----> Unsetting myapp
-----> Unsetting DOKKU_NGINX_PORT
-----> Unsetting DOKKU_NGINX_SSL_PORT
-----> Unsetting DOKKU_PROXY_PORT_MAP
-----> Setting config vars
       NO_VHOST: 1
-----> no nginx port set. setting to random open high port
-----> Setting config vars
       DOKKU_NGINX_PORT: 17518
-----> Setting config vars
       DOKKU_PROXY_PORT_MAP: http:17518:5000
-----> Creating http nginx.conf
-----> Running nginx-pre-reload
       Reloading nginx
-----> Setting config vars
-----> Attempting to run scripts.dokku.postdeploy from app.json (if defined)
=====> Application deployed:
       http://139.59.XX.XXX:XXXXXTo 139.59.XX.XXX:myapp
 * [new branch]      master -> master

🎉 Congratulations! You have your application live now.

Just click on the link( http://139.59.XX.XXX:XXXXX) provided by dokku or copy and paste this into chrome and Enjoy!.

🎥 In Case, Here is the video


Next week we will learn how to make our dokku application SSL Secure / HTTPS. Stay Tuned.

Happy Coding !

If you like this article, please ❤/👏 or share it! For more like this, follow me on Medium or Twitter. To ask a Question visit this link. More about me on mywebsite.

Don’t forget to subscribe our weekly-newsletter service for web hackers. All latest articles and stuff like trending repositories, straight to your mailbox.


Stories for Full-Stack Web developers which help them in pursuing their goals as a developer, mastering the modern web technologies and *hacking the web.

Gaurav Mehla

Written by

Software engineer & Web hacker. Spent 30+% of life on playing with JS



Stories for Full-Stack Web developers which help them in pursuing their goals as a developer, mastering the modern web technologies and *hacking the web.