Getting Started with Clojure on Heroku

Last week I introduced the Den of Clojure to Heroku. I really enjoyed learning more about Clojure and experiencing super simple Clojure deployment on Heroku. For those who haven’t yet deployed Clojure on Heroku, lets walk through 8 quick steps to get you started:

To upload this application to Heroku you will first need to create a Git repository, add the files to it, and commit them:

git initgit add project.clj src
git commit-m init

Now create a new application on Heroku:

heroku create

This creates an HTTP and a Git endpoint for your application. The Git endpoint will be added to your Git configuration as a “remote” named “heroku”.

Upload your Git repository to the Git repository for your application on Heroku:

git push heroku master

This will kick off the Leiningen build process on Heroku. The build will download the dependencies for the app then compile the app and put everything into a “slug” that will be deployed onto a Dyno. Once the process is complete you can open the HTTP endpoint for your app in your browser:

If you’re on Leiningen 2.x (and if you’re not, you should try it), you can run `lein new heroku myapp` to have a ready-made skeleton project written with Compojure, a Procfile, etc. I should have a new version out soon that adds support for easier environment config and embeds an HTTP repl server.