public
Created

NY Java SIG

  • Download Gist
prerequisites.md
Markdown
session.md
Markdown

Heroku Basics

Heroku is a Cloud Application Platform

  • Supports Java, Scala, Python, Node.js, Ruby, etc
  • Instant Deployment via Git or WAR files
  • Instant Scalability
  • Managed Infrastructure: Servers, Load Balancers, Databases, etc
  • Extended via Add-ons: http://addons.heroku.com

Heroku Basics

Deployment

  1. Copy git repo to Heroku:

    git push heroku master
    
  2. Heroku compiles code

  3. Heroku creates a "slug" file

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

  5. Heroku starts the process

Terminology

http://heroku.com/how

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

Pricing

http://www.heroku.com/pricing

$0.05 / dyno hour

750 free dyno hours per application per month

Deploy An App

  1. In Eclipse select File > New > Other...
  2. Expand the Heroku section, select Create Heroku App from Template, select Next
  3. Select Spring MVC & Tomcat application, select Finish

Open the App

  1. In Eclipse select Window > Show View > Other...
  2. Expand the Heroku section, select My Heroku Applications, select Ok
  3. Locate the newly created application in My Heroku Applications
  4. Right-click on the application and select Open

Run the App Locally

  1. In Eclipse select Run > Run Configurations...
  2. Double-click on Java Application
  3. Set the name to something like arcane-taiga-7336 webapp-runner (using the application's name)
  4. Set the Main class to webapp.runner.launch.Main
  5. In the Arguments tab add src/main/webapp as a Program argument
  6. Select Run
  7. Visit http://localhost:8080

About the App

  • BYOC via pom.xml
  • Define processes via the Procfile
  • Database configured via the DATABASE_URL environment variable

Deploy Changes

  1. Make a change to the application and test locally
  2. In Eclipse right-click on the project name in the Project Explorer
  3. Select Team > Commit...
  4. Enter a Commit message
  5. Select Commit
  6. Right-click on the project name in the Project Explorer
  7. Select Team > Push to Upstream
  8. View the application on Heroku in your browser

View Logs

  1. In Eclipse select the My Heroku Applications tab
  2. Right-click on the application and select View logs

Scale the App

This requires a verified account on Heroku: http://heroku.com/verify

  1. In Eclipse select the My Heroku Applications tab
  2. Right-click on the application and select Scale
  3. Enter the number of Dynos to scale the web process to
  4. Select Ok

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.