So I decided that I should probably look into Vagrant as it would let me easily provision different development environments lickity split via Virtualbox
Afterwards I decided to look into Docker as it was now > v1.0.0 which means it’s ready for production, right? More on that another time.
During my venture in to the world of Docker I discovered Dokku. My very own private Heroku.
Now this was getting interesting…
Digital Ocean has a Ubuntu + Dokku ready image that can be deployed and tried out for pennies. But what if I wanted to work on my local development machine and have it be the same as on Digital Ocean?
Install Dokku
1 2 |
|
Start the VM
This assumes you have already installed Vagrant and Virtualbox
1
|
|
Vagrant will automagically provision and start the VM with Docker, Git, Nginx and anything else Dokku needs to work… This means from scratch downloading and installing the packages in the VM and even the VM itself if you didn’t already have it.
Yes, that could take a little while (after downloading the VM image Vagrant will cache it locally so it’ll be faster next time around).
Add some entries to /etc/hosts
The running Dokku server will be on IP address 10.0.0.2, with a hostname of dokku.me
In order to make it easier to deploy and run applications we’ll need to add some entries to your /etc/hosts file - one for the Dokku server and another for a sample app, which we’ll use to verify it’s all working as expected.
1 2 |
|
This will also allow us to access deployed applications via URLs like http://sample-node-app.dokku.me
instead of IP address and port number.
Add vagrant SSH key to the running Dokku server
I think this should be done by the the Dokku/Vagrant script but for some reason it didn’t on my machine so I had to do this manually.
1
|
|
Add your SSH key to the running Dokku server
In order to deploy your code to the Dokku server it needs your SSH key.
1
|
|
What’s happening here? Let’s break it down:
- Your public SSH key file is being piped…
cat ~/.ssh/id_dsa.pub |
- to a shell session at dokku.me with user dokku…
ssh dokku@dokku.me
(That entry in your /etc/hosts file made it easier as you can usedokku.me
instead of10.0.0.2
) - Inside the Dokku shell session some commands are executed, which will receive your SSH key…
"sudo sshcommand acl-add dokku jeremychu”
This will Add a named SSH key jeremychu
to the user dokku
. See the sshcommand on Github for more info.
If it all went well you should see something like the following, say yes and proceed.
1 2 3 4 5 |
|
If it works you should be able to SSH into dokku.me and call the Dokku version
command:
1 2 |
|
Grab a sample app from Github
1 2 |
|
Add the local Dokku server as a Git Remote
1
|
|
Now deploy the app (I find this part rather special):
1
|
|
If it all worked you should see something similar to the following (trimmed for readability):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
Now point your browser at sample-node-app.dokku.me
Delete the sample app
When you’re finished you can delete the app by calling:
1
|
|
Note: This is run on the host OS and not inside the Dokku VM (so on my Macbook Pro I would just run this inside a terminal window).