As we already wrote a lot about our beautiful frontend and especially about our sofa.io platform, we felt it was time to also give some insights about what is running behind the scenes at couchcommerce.
A couple of weeks ago we started to rewrite our API, that is used by our webapp to handle the checkout process (more details on this later). So after a few days of coding, we thought about how and where to deploy our application. As we recently discovered Docker and quickly became big fans, we looked for a way to make use of its power on our test system. Furthermore, we were looking for a possiblity to seemlessly integrate the process of deploying an application into our git workflow. That’s how we found Dokku. Dokku is a “Docker-based mini-heroku”. So what this means for a deployment is, that you simply do a “git push” to a previously created git remote. Then, dokku automatically detects which language the application is written in and serves it to the web from a fresh Docker container. This is a really convenient method to quickly make an application accessible to the web without the need of any additional configuration on the server. For example you could deploy a node.js application and a PHP application on a server without having to install node.js or php-fpm because all the requirements are included in the corresponding buildpack. Also, you can easily remove the application from your server via “dokku delete <appname>” which will delete the application’s files (including configuration) and its docker container. And again, there is no additional cleanup work needed on your server as all the required software was included in the buildpack / docker container.
Getting deploy-ready with dokku is really easy, it’s basically 3 steps:
- Install dokku on your server (this will create a dokku user on that machine)
- Add your ssh public key from your local machine to the dokku user’s authorized_keys file (be sure to use sshcommand for that)
- Add a new git remote to to your project
- push your master branch to that remote
Dokku generally only supports pushing to the master branch of your project. However, you can also use it to deploy other branches or tags. For instance if you have created a new git remote called “testing” to deploy your application and would like to deploy a tag “1.0.1”, then you could do this with “git push testing refs/tags/1.0.1:master”.
Dokku comes with a nice plugin system and there is a bunch of useful community plugins. For instance we are using plugins for rabbitmq, forego, postgresql and redis. In many cases the plugin will just start a new docker container that you can link with your application. For example with the redis plugin, it goes like this:
dokku redis:create myredis // create the new container
dokku redis:info myredis // show info about redis
dokku redis:link myapp myredis // link application with the redis container
Check out the dokku github page for more detailed information. There is also a pretty good video tutorial about getting started with dokku on vimeo. Another article worth reading is “How Dokku Works” from Rico Moorman.