As I said previously, it’s very easy to turn Linux machine into Heroku-like server. But, before setting up paying account on Amazon or Digital Ocean, it’s nice to just play it locally. Will do that, running a Dokku on virtual machine. Will setup development environment and do first local deployment, just to see some real features.
It does not require complex environment to run Dokku locally. All you need is
You box should contain few things: git (github account), VirtualBox and Vagrant. If you don’t have Vagrant installed, please do now. It makes a lot of sense to keep such kind software on machine.
Here you can find some instructionn of how to do that.
You should clone Dokku repo locally. In your development folder, run
Dokku repository already contains Vagrant file, with all required configuration.
Just in sake of convenience, will map
10.0.0.2 ip address (the one that Vagrant machine is assigned with), to
dokku.me DNS name, so it’s just handy for testing.
and put last 2 lines, as it shown in my example:
1 2 3 4 5 6 7 8 9 10 11 12
dokku folder, you should run
It will start to prepare new virtual environment for you,
1 2 3 4 5 6 7 8 9 10 11 12 13
I have a problem with this step few times, so if you machine could not be booted, try to run
vagrant reload, it should help.
It would took about up to 20 minutes, to fire up virtual machine, install git there, install Docker + Dokku. As soon as it’s done, it’s possible to access machine by
Last thing you need to do, is to upload your
ssh key to Dokku server, so you will be to
git push code there.
You can use default vagrant root password, which is
Now, just to check that everything is fine simply access you machine by
So, just try that everything is running fine by checking version of Docker:
The instance is ready for deployment.
If you still there, you can just quit vagrant
ssh session, and went to the folder with Node.js application. I’ll be using really simple app, called
Node-simple – express.js based, that serves one HTML file and shows
NODE_ENV env. variable.
So, what you need to setup is remote repository to push to:
That’s all. You ready for first deploy, just push code to machine with Dokku:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
Every application requires environment. It’s common practice to set at least
NODE_ENV variable for Node.js applications. To do that, you need to create
ENV file inside the
Now, let’s re-deploy the application, change the version in
package.json and push code again.
Now, application is ready to be accessed.
Open Chrome and hit
http://node-simple.dokku.me, so you will see such response:
You can play a bit further, by just changing some Node.js code of end-points and re-deploy. Each time, new docker instance is started and served on
http://node-simple.dokku.me. The experience of deployment is really like something you have with Heroku.
Just looking on logs while new application is deployed, would give pretty much idea of what’s going on there.
So, your local Vagrant image will good start place, before you ready to use Dokku on cloud.