Clojure Deploying Like a Boss

Clojure is cool, with the help of JVM and lein, we can easily build and compile a web app from scratch.

And one of my favourite feature in clojure is compiling the source code into a single jar (or war). Unlike Ruby/Python/PHP, all we have to do is:

  1. upload the compiled (standalone) jar to server,
  2. restart the service.

Homebrew solution

After a few investigations, I developed this approach to deploy my app:

  1. make some changes to the source code,
  2. commit the changeset,
  3. push to the upstream,
  4. use fabric to deploy the latest code (of course auto pull in server side is much better),
  5. pull out the latest code in the target server,
  6. compile the code into standalone jar (if necessary),
  7. rebuild the docker image (if necessary),
  8. restart the docker container service.


  • Why use docker?

By employing docker, we can ensure the server environment and the develop environment stay the same.

  • Why compile in the target server?

Because the upload speed in China is painful slow. A better way is to setup a build server and make it compile the latest codebase automatically.

I will continually update this post when hanging out with clojure. :D

Since 2014