Skip to content

Instantly share code, notes, and snippets.

@weavejester
Created May 31, 2011 20:27
Show Gist options
  • Save weavejester/1001206 to your computer and use it in GitHub Desktop.
Save weavejester/1001206 to your computer and use it in GitHub Desktop.
Clojure on Heroku
~/$ lein new ring-on-heroku
Created new project in: /home/jim/Development/ring-on-heroku
~/$ cd ring-on-heroku
~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile
~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj
(ns ring-on-heroku.core
(:use ring.util.response
ring.adapter.jetty))
(defn app [req]
(response "Hello World"))
(defn -main []
(let [port (Integer/parseInt (get (System/getenv) "PORT" "8080"))]
(run-jetty app {:port port})))
~/ring-on-heroku$ cat > project.clj
(defproject ring-on-heroku "1.0.0-SNAPSHOT"
:description "Example Ring app running on Heroku"
:dependencies [[org.clojure/clojure "1.2.1"]
[ring/ring-core "0.3.8"]
[ring/ring-jetty-adapter "0.3.8"]])
~/ring-on-heroku$ git init
Initialized empty Git repository in /home/jim/Development/ring-on-heroku/.git/
~/ring-on-heroku$ git add .
~/ring-on-heroku$ git commit -m "Initial commit"
[master (root-commit) c09dde7] Initial commit
6 files changed, 40 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 Procfile
create mode 100644 README
create mode 100644 project.clj
create mode 100644 src/ring_on_heroku/core.clj
create mode 100644 test/ring_on_heroku/test/core.clj
~/ring-on-heroku$ heroku create --stack cedar
Creating fierce-fog-647... done
http://fierce-fog-647.heroku.com/ | [email protected]:fierce-fog-647.git
Git remote heroku added
~/ring-on-heroku$ git push heroku master
Warning: Permanently added the RSA host key for IP address '50.19.85.156' to the list of known hosts.
Counting objects: 13, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (13/13), 1.30 KiB, done.
Total 13 (delta 0), reused 0 (delta 0)
-----> Heroku receiving push
-----> Clojure app detected
-----> Installing Leiningen
Downloading: leiningen-1.5.2-standalone.jar
Writing: lein script
-----> Installing dependencies with Leiningen
Running: lein deps :skip-dev
Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.pom from central
Downloading: ring/ring-core/0.3.8/ring-core-0.3.8.pom from central
Downloading: ring/ring-core/0.3.8/ring-core-0.3.8.pom from clojure
Downloading: ring/ring-core/0.3.8/ring-core-0.3.8.pom from clojars
Transferring 2K from clojars
Downloading: org/clojure/clojure/1.2.0/clojure-1.2.0.pom from clojure
Transferring 1K from clojure
Downloading: commons-codec/commons-codec/1.4/commons-codec-1.4.pom from clojure
Downloading: commons-codec/commons-codec/1.4/commons-codec-1.4.pom from clojars
Downloading: commons-codec/commons-codec/1.4/commons-codec-1.4.pom from central
Downloading: org/apache/commons/commons-parent/11/commons-parent-11.pom from clojure
Downloading: org/apache/commons/commons-parent/11/commons-parent-11.pom from clojars
Downloading: org/apache/commons/commons-parent/11/commons-parent-11.pom from central
Downloading: org/apache/apache/4/apache-4.pom from clojure
Downloading: org/apache/apache/4/apache-4.pom from clojars
Downloading: org/apache/apache/4/apache-4.pom from central
Downloading: commons-io/commons-io/1.4/commons-io-1.4.pom from clojure
Downloading: commons-io/commons-io/1.4/commons-io-1.4.pom from clojars
Downloading: commons-io/commons-io/1.4/commons-io-1.4.pom from central
Downloading: org/apache/commons/commons-parent/7/commons-parent-7.pom from clojure
Downloading: org/apache/commons/commons-parent/7/commons-parent-7.pom from clojars
Downloading: org/apache/commons/commons-parent/7/commons-parent-7.pom from central
Downloading: commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.pom from clojure
Downloading: commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.pom from clojars
Downloading: commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.pom from central
Downloading: javax/servlet/servlet-api/2.5/servlet-api-2.5.pom from clojure
Downloading: javax/servlet/servlet-api/2.5/servlet-api-2.5.pom from clojars
Downloading: javax/servlet/servlet-api/2.5/servlet-api-2.5.pom from central
Downloading: ring/ring-jetty-adapter/0.3.8/ring-jetty-adapter-0.3.8.pom from central
Downloading: ring/ring-jetty-adapter/0.3.8/ring-jetty-adapter-0.3.8.pom from clojure
Downloading: ring/ring-jetty-adapter/0.3.8/ring-jetty-adapter-0.3.8.pom from clojars
Transferring 2K from clojars
Downloading: ring/ring-servlet/0.3.8/ring-servlet-0.3.8.pom from clojure
Downloading: ring/ring-servlet/0.3.8/ring-servlet-0.3.8.pom from clojars
Transferring 1K from clojars
Downloading: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.pom from clojure
Downloading: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.pom from clojars
Downloading: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.pom from central
Downloading: org/mortbay/jetty/project/6.1.26/project-6.1.26.pom from clojure
Downloading: org/mortbay/jetty/project/6.1.26/project-6.1.26.pom from clojars
Downloading: org/mortbay/jetty/project/6.1.26/project-6.1.26.pom from central
Downloading: org/mortbay/jetty/jetty-parent/10/jetty-parent-10.pom from clojure
Downloading: org/mortbay/jetty/jetty-parent/10/jetty-parent-10.pom from clojars
Downloading: org/mortbay/jetty/jetty-parent/10/jetty-parent-10.pom from central
Downloading: org/eclipse/jetty/jetty-parent/14/jetty-parent-14.pom from clojure
Downloading: org/eclipse/jetty/jetty-parent/14/jetty-parent-14.pom from clojars
Downloading: org/eclipse/jetty/jetty-parent/14/jetty-parent-14.pom from central
Downloading: org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.pom from clojure
Downloading: org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.pom from clojars
Downloading: org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.pom from central
Downloading: org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.pom from clojure
Downloading: org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.pom from clojars
Downloading: org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.pom from central
Downloading: org/mortbay/jetty/jetty-parent/7/jetty-parent-7.pom from clojure
Downloading: org/mortbay/jetty/jetty-parent/7/jetty-parent-7.pom from clojars
Downloading: org/mortbay/jetty/jetty-parent/7/jetty-parent-7.pom from central
Downloading: org/clojure/clojure/1.2.1/clojure-1.2.1.jar from central
Downloading: ring/ring-core/0.3.8/ring-core-0.3.8.jar from central
Downloading: ring/ring-core/0.3.8/ring-core-0.3.8.jar from clojure
Downloading: ring/ring-core/0.3.8/ring-core-0.3.8.jar from clojars
Transferring 16K from clojars
Downloading: commons-codec/commons-codec/1.4/commons-codec-1.4.jar from clojure
Downloading: commons-codec/commons-codec/1.4/commons-codec-1.4.jar from clojars
Downloading: commons-codec/commons-codec/1.4/commons-codec-1.4.jar from central
Downloading: commons-io/commons-io/1.4/commons-io-1.4.jar from clojure
Downloading: commons-io/commons-io/1.4/commons-io-1.4.jar from clojars
Downloading: commons-io/commons-io/1.4/commons-io-1.4.jar from central
Downloading: commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar from clojure
Downloading: commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar from clojars
Downloading: commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar from central
Downloading: javax/servlet/servlet-api/2.5/servlet-api-2.5.jar from clojure
Downloading: javax/servlet/servlet-api/2.5/servlet-api-2.5.jar from clojars
Downloading: javax/servlet/servlet-api/2.5/servlet-api-2.5.jar from central
Downloading: ring/ring-jetty-adapter/0.3.8/ring-jetty-adapter-0.3.8.jar from central
Downloading: ring/ring-jetty-adapter/0.3.8/ring-jetty-adapter-0.3.8.jar from clojure
Downloading: ring/ring-jetty-adapter/0.3.8/ring-jetty-adapter-0.3.8.jar from clojars
Transferring 2K from clojars
Downloading: ring/ring-servlet/0.3.8/ring-servlet-0.3.8.jar from clojure
Downloading: ring/ring-servlet/0.3.8/ring-servlet-0.3.8.jar from clojars
Transferring 3K from clojars
Downloading: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar from clojure
Downloading: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar from clojars
Downloading: org/mortbay/jetty/jetty/6.1.26/jetty-6.1.26.jar from central
Downloading: org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar from clojure
Downloading: org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar from clojars
Downloading: org/mortbay/jetty/jetty-util/6.1.26/jetty-util-6.1.26.jar from central
Downloading: org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar from clojure
Downloading: org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar from clojars
Downloading: org/mortbay/jetty/servlet-api/2.5-20081211/servlet-api-2.5-20081211.jar from central
Copying 11 files to /tmp/build_3fg55ekdqxz4k/lib
-----> Discovering process types
Procfile declares types -> web
-----> Compiled slug size is 11.0MB
-----> Launching... done, v4
http://fierce-fog-647.herokuapp.com deployed to Heroku
To [email protected]:fierce-fog-647.git
* [new branch] master -> master
Copy link

ghost commented Jun 2, 2011

This is going to be HUGE!

@devn
Copy link

devn commented Jun 3, 2011

zkim, I had to remove the PORT env var in order to get it to work.

My code is more or less verbatim, but IIRC I made a small change or two. I'll push my skeleton project soon-ish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment