Node.js Deployment; Docker, Dokku & Digital Ocean

DigitalOcean is a really nice cloud hosting company that offers excellent performance at affordable rates

Docker is an abstraction on top of LXC Containers. Docker introduces a workflow that makes operating containers straightforward and lots of fun.

Dokku is a tiny program that allows you to easily deploy your applications. It was built by progrium (from localtunnel) on top of docker, Buildstep, gitreceive, pluginhook, nginx, Heroku BuildPacks,& sshcommand


Register with Digital Ocean and add your SSH key

Create a new droplet using the latest Ubuntu making sure you select your ssh key. Go for a 1GB+ droplet

As soon as your server is ready you can connect via SSH

ana@local: ssh root@123.456.678.9

If you get prompted for a password you forgot to add your SSH key to the server. You can still login in using a password (it’s in your email). Connect to your server using the root password and add your key to ~/.ssh/authorized_keys

Installing dokku is easy

root@dinospace: wget -qO- \\ \\  
 | sudo bash

Dokku works best with a domain so applications can respond to instead of

Add these A records to your domain making sure they point to your server. You can even do this in the DigitalOcean Control Panel if you configured your domain to use their name servers

Type  Host                      Answer         TTL    
A    123.456.678.9  30    
A     \*  123.456.678.9  30

If you really want to have fun doing this check out the dnsd and geoip modules and build your own dns server for fun and profit!!11!one!

You can now connect to your server using your domain name

ana@local: ssh

Dokku uses the /home/dokku/VHOST file to store your domain name so make sure is in there

root@dinospace: touch /home/dokku/VHOST    
root@dinospace: echo > /home/dokku/VHOST

To give yourself (and others) permission to deploy use the sshcommand program

ana@local: cat ~/.ssh/id\ | \\    
  ssh \\  
  "sudo sshcommand acl-add dokku username"

Don’t use ssh-copy-id: This would give users full access to your server and they wouldn’t be able to git push because it uses the git user

Deploy your first application: Tiny; a node.js based url shortener

ana@local: git clone    
ana@local: cd tiny

Tiny responds to two kinds of HTTP requests

\# minimize a url  
POST /create&url=
\# get the redirect for a minimized url  
GET  /hN1x

We can deploy tiny by git pushing from our machine to the server

ana@local: git remote add dinospace \\  
ana@local: git push dinospace master

On the server you can use docker to check if the process is running

root@dinospace: docker ps -a    
ID           IMAGE    
9f033c42189e app/tiny:latest

Shorten your first URL. What better pick than

ana@local: curl -X POST \\\=  

Resolving the shortened version

**ana@local**: curl -I    
HTTP/1.1 302 Moved Temporarily    
Server: nginx/1.2.6 (Ubuntu)    
Date: Sat, 03 Aug 2013 01:54:40 GMT    
Connection: keep-alive    
Location: [](


Docker provides you easy access to logs

root@dinospace: docker logs 9f033c42189e    

Environment variables are commonly used to store secrets such as api keys or passwords. Dokku support this functionality out of the box

root@dinospace: touch /home/git/tiny/ENV    
echo "export FOO=BAR" >> /home/git/tiny/ENV

This is all for now

Written by Nuno Job

Originally published at on March 26, 2014.

Written by YLDMarch 26th, 2014

Share this article

Find us

London - HQ

9 Dallington Street



+44(0) 203 514 4678


Rua Ramalho Ortigão 8

3º Esquerdo




Rua Sá da Bandeira 819

2º Esquerdo