Push Local Changes

Page last updated:

Page last updated:

In this step you’ll learn how to propagate a local change to the application through to Cloud Foundry. As a simple change, we’ll modify the title which the app shows.

Change the return string for the root route in the src/cf_sample_app_clojure/core.clj file to ‘I am awesome!’. Your final result should look something like this:

(ns cf-sample-app-clojure.core
   (:gen-class)
   (:require [compojure.core :refer :all]
             [compojure.route :as route]
             [ring.adapter.jetty :as jetty]
             [ring.middleware.defaults :refer [wrap-defaults site-defaults]]))

(defroutes app-routes
  (GET "/" [] "I am awesome!")
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (wrap-defaults app-routes site-defaults))

(defn -main
  [& [port]]
  (let [port (Integer. (or port (System/getenv "PORT") 3000))]
    (jetty/run-jetty #'app {:port  port
                            :join? false})))

Now test locally:

$ lein run

Visiting your application at http://localhost:3000, you should see the message changed. You are awesome!

Now deploy. First rebuild the jar file:

$ lein uberjar

Then all you need to do is cf push again:

$ cf push my-clojure-app -b java_buildpack -p target/cf-sample-app-clojure-0.1.0-SNAPSHOT-standalone.jar

Finally, check that everything is working by visiting your app’s URL from your web browser.

I can push local changes
View the source for this page in GitHub