Save 37% off PRO during our Black Friday Sale! »

Heroku at BattleHack Venice 2015

Heroku at BattleHack Venice 2015

D6ccd6409910643d05ddaea3b2cd6f13?s=128

David Zuelke

July 11, 2015
Tweet

Transcript

  1. HEROKU IN FIVE MINUTES BattleHack Venice 2015

  2. None
  3. Platform-as-a-Service

  4. None
  5. Sign up for free at heroku.com!

  6. FAST AND EASY DEPLOYS Sync from Dropbox, GitHub, or the

    code on your computer.
  7. Demo

  8. None
  9. None
  10. FORKING APPS $  heroku  fork  -­‐-­‐from  sourceapp  -­‐-­‐to  targetapp  

    Creating  fork  targetapp...  done   Copying  slug...  done   Adding  heroku-­‐postgresql:dev...  done   Creating  database  backup  from  sourcapp...  ..  done   Restoring  database  backup  to  targetapp...  ..  done   Copying  config  vars...  done   Fork  complete,  view  it  at  http://targetapp.herokuapp.com/
  11. “The Twelve-Factor App”

  12. 12factor.net

  13. II. DEPENDENCIES Applications have explicitly declared dependencies.

  14. II. DEPENDENCIES Applications have explicitly declared dependencies. $  cat  composer.json

      {      "require":  {          "php":  ">=5.3.3",          "ext-­‐mcrypt":  "*",          "symfony/symfony":  "~2.4.6",          "twig/extensions":  "~1.0",          "symfony/monolog-­‐bundle":  "~2.4"      }   } $  cat  package.json   {      "dependencies":  {          "express":  "~4.9.x",          "cool-­‐ascii-­‐faces":  "~1.3.x"      },      "engines":  {          "node":  "0.10.x"      }   }
  15. do not check your dependencies into Git

  16. III. CONFIGURATION Store config in the environment.

  17. III. CONFIGURATION Store config in the environment. Assumption: same code

    but different configuration per deployment target
  18. III. CONFIGURATION Store config in the environment. $smtp  =  parse_url(getenv('SMTP_GATEWAY_URL'));

      $transport  =  Swift_SmtpTransport::newInstance(
        $smtp['host'],  $smtp['port']
 )
        -­‐>setUsername($smtp['user'])
        -­‐>setPassword($smtp['pass'])
 ; Assumption: same code but different configuration per deployment target $  heroku  config:set  SMTP_GATEWAY_URL=\   smtp://joecool:itwasadarkandstormynight@smtp.blah.com:827
  19. do not hardcode config vars, they might change suddenly!

  20. VI. PROCESSES heroku-­‐python-­‐app  $  cat  Procfile   worker:  python  worker.py

      web:  gunicorn  hello:app heroku-­‐node-­‐app  $  cat  Procfile   worker:  node  worker.js   web:  node  index.js heroku-­‐ruby-­‐app  $  cat  Procfile   worker:  env  TERM_CHILD=1  bundle  exec  rake  resque:work   web:  bundle  exec  unicorn  -­‐p  $PORT  -­‐c  ./config/unicorn.rb heroku-­‐php-­‐app  $  cat  Procfile   worker:  php  background.php   web:  vendor/bin/heroku-­‐php-­‐apache2  #  or  heroku-­‐php-­‐nginx
  21. SCALING

  22. SCALING $  heroku  ps:scale  web=5   Scaling  dynos...  done,  now

     running  web  at  5:1X.   $  heroku  ps   ===  web  (1X):  `bundle  exec  unicorn  -­‐p  $PORT`   web.1:  starting  2014/11/05  20:36:39  (~  4s  ago)   web.2:  starting  2014/11/05  20:36:39  (~  4s  ago)   web.3:  starting  2014/11/05  20:36:39  (~  4s  ago)   web.4:  starting  2014/11/05  20:36:38  (~  4s  ago)   web.5:  starting  2014/11/05  20:36:38  (~  4s  ago)   ===  worker  (Free):  `bundle  exec  stalk  worker.rb`   worker.1:  up  for  1m   $  heroku  ps:scale  web=1   Scaling  dynos...  done,  now  running  web  at  1:1X.
  23. None
  24. Demo

  25. ADD-ONS

  26. your app needs a relational database

  27. your app needs a document database

  28. your app needs an email gateway

  29. your app needs a search engine

  30. your app needs an analytics engine

  31. your app needs a log storage

  32. your app needs... add-ons!

  33. $  heroku  addons:create  heroku-­‐postgresql

  34. $  heroku  addons:create  heroku-­‐redis

  35. $  heroku  addons:create  mongolab

  36. $  heroku  addons:create  memcachier

  37. $  heroku  addons:create  foundelasticsearch

  38. $  heroku  addons:create  cloudamqp

  39. $  heroku  addons:create  papertrail

  40. $  heroku  addons:create  newrelic

  41. $  heroku  addons:create  sendgrid

  42. $  heroku  addons:create  pusher

  43. 150+ ADD-ONS, USE THEM! http://elements.heroku.com/

  44. Demo

  45. GOOD LUCK!

  46. None
  47. xkcd.com/323

  48. None
  49. The End

  50. THANK YOU FOR LISTENING! Questions? Ask me: @dzuelke & dz@heroku.com