Skip to content

Instantly share code, notes, and snippets.

@bltavares
Last active January 4, 2016 03:39
Show Gist options
  • Save bltavares/8563326 to your computer and use it in GitHub Desktop.
Save bltavares/8563326 to your computer and use it in GitHub Desktop.

quick-heroku

Containerized ephemeral heroku-like local environment

Requirements

Usage

./quick-heroku my/app/location awesome 5000

Example

vagrant@precise64:~$ ls heroku-clojure-helloworld/
Procfile  project.clj  README.md  resources  src  test
vagrant@precise64:~$ ./quick-heroku heroku-clojure-helloworld test 5000
       Clojure (Leiningen 2) app detected
-----> Installing OpenJDK 1.6...done
-----> Installing Leiningen
       Downloading: leiningen-2.3.4-standalone.jar
       Writing: lein script
-----> Building with Leiningen
       Running: lein with-profile production compile :all
       Retrieving environ/environ.lein/0.2.1/environ.lein-0.2.1.pom from clojars
[...]
Compiling helloworld.web
-----> Discovering process types
       Procfile declares types -> web
       Default process types for Clojure (Leiningen 2) -> webStarting web app
App running...
0.0.0.0:49155
Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
Picked up JAVA_TOOL_OPTIONS:  -Djava.rmi.server.useCodebaseOnly=true
2014-01-22 17:49:25.143:INFO:oejs.Server:jetty-7.6.1.v20120215
2014-01-22 17:49:25.211:INFO:oejs.AbstractConnector:Started [email protected]:5000^Z
[1]+  Stopped                 ./start.sh heroku-clojure-helloworld test 5000
vagrant@precise64:~$ curl localhost:49155
["Hello" :from Heroku]
vagrant@precise64:~$ fg
./quick-heroku heroku-clojure-helloworld test 5000
#!/bin/bash
APP_LOCATION=$1
APP_NAME=$2
PORT=$3
echo "Building application package..."
tar cC $APP_LOCATION . | buildstep $APP_NAME
echo "Starting web app"
APP_CONTAINER=$(docker run -d -p $PORT $APP_NAME /bin/bash -c "/start web")
echo "App running..."
docker port $APP_CONTAINER $PORT
docker logs -f $APP_CONTAINER
echo "Killing container"
docker kill $APP_CONTAINER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment