Skip to content

@jamesward /

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Den of Clojure

Heroku @ Den of Clojure

About James Ward

Java Developer since: 1997

First Programming Language: Pascal

Favorite Programming Language: x86 Assembler

Heroku Clojure Quick Start

Seven steps to the Cloud

  1. project.clj

    (defproject hello-world "0.0.1"
      :dependencies [[org.clojure/clojure "1.3.0"]
                     [ring/ring-jetty-adapter "1.0.1"]])
  2. src/web.clj

    (ns web
      (:use [ring.adapter.jetty :only [run-jetty]]))
    (defn app [req]
      {:status 200
       :headers {"Content-Type" "text/plain"}
       :body "Hello, world"})
    (defn -main [port]
      (run-jetty app {:port (Integer. port)}))
  3. Procfile

    web: lein trampoline run -m web $PORT
  4. Commit the files to a Git repo:

    git init
    git add Procfile project.clj src
    git commit -m init
  5. Create a new app on Heroku:

    heroku create
  6. Push the app to Heroku:

    git push heroku master
  7. Open the app:

    heroku open

Heroku Basics

So simple.


  1. Copy git repo to Heroku:

    git push heroku master
  2. Heroku uses a "Buildpack" to compile code

  3. Heroku creates a "slug" file

  4. Heroku deploys "slug" onto a "dyno"

  5. Heroku starts the process


User has 0 or more Applications

Application has 1 git repository

Application has 0 or more Processes

Process is defined in a Procfile

Process named "web" can listen on one port for HTTP

Process runs on 0 or more Dynos

Dynos are isolated (LXC) and managed execution environments

Application has 0 more more external resources - Heroku Add-ons

Buildpack receives a git push and produces a "slug"

Slug contains the non-system dependencies for all Processes

Dynos are ephemeral and stateless

HTTP(s) requests are randomly routed to the "web" Dynos


$0.05 / dyno hour

750 free dyno hours per application per month

The Heroku CLI

$ heroku help

Heroku Add-ons

Add-ons are third party cloud services for things like caching, databases, monitoring, management, etc

Noir on Heroku

Small and simple is wonderful.

  • project.clj

    (defproject hello-clojure-compojure "0.1.0-SNAPSHOT"
      :main web
      :dependencies [[org.clojure/clojure "1.4.0"]
                     [noir "1.2.1"]])
  • src/web.clj

    (ns web
      (:use noir.core)
      (:require [noir.server :as server]))
    (defpage "/" [] "hello, world")
    (server/start (Integer/parseInt (or (System/getenv "PORT") "8080")))
  • Procfile

    web: lein trampoline run

Heroku for Clojure

Links to help you get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.