$30 off During Our Annual Pro Sale. View Details »

Heroku at BattleHack Venice 2015

Heroku at BattleHack Venice 2015

David Zuelke

July 11, 2015
Tweet

More Decks by David Zuelke

Other Decks in Programming

Transcript

  1. HEROKU IN
    FIVE MINUTES
    BattleHack Venice 2015

    View Slide

  2. View Slide

  3. Platform-as-a-Service

    View Slide

  4. View Slide

  5. Sign up for free at heroku.com!

    View Slide

  6. FAST AND EASY DEPLOYS
    Sync from Dropbox, GitHub, or the code on your computer.

    View Slide

  7. Demo

    View Slide

  8. View Slide

  9. View Slide

  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/

    View Slide

  11. “The Twelve-Factor App”

    View Slide

  12. 12factor.net

    View Slide

  13. II. DEPENDENCIES
    Applications have explicitly declared dependencies.

    View Slide

  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"  
       }  
    }

    View Slide

  15. do not check your dependencies into Git

    View Slide

  16. III. CONFIGURATION
    Store config in the environment.

    View Slide

  17. III. CONFIGURATION
    Store config in the environment.
    Assumption:
    same code but different configuration per deployment target

    View Slide

  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:[email protected]:827

    View Slide

  19. do not hardcode config vars, they might change suddenly!

    View Slide

  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

    View Slide

  21. SCALING

    View Slide

  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.

    View Slide

  23. View Slide

  24. Demo

    View Slide

  25. ADD-ONS

    View Slide

  26. your app needs a relational database

    View Slide

  27. your app needs a document database

    View Slide

  28. your app needs an email gateway

    View Slide

  29. your app needs a search engine

    View Slide

  30. your app needs an analytics engine

    View Slide

  31. your app needs a log storage

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  35. $  heroku  addons:create  mongolab

    View Slide

  36. $  heroku  addons:create  memcachier

    View Slide

  37. $  heroku  addons:create  foundelasticsearch

    View Slide

  38. $  heroku  addons:create  cloudamqp

    View Slide

  39. $  heroku  addons:create  papertrail

    View Slide

  40. $  heroku  addons:create  newrelic

    View Slide

  41. $  heroku  addons:create  sendgrid

    View Slide

  42. $  heroku  addons:create  pusher

    View Slide

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

    View Slide

  44. Demo

    View Slide

  45. GOOD LUCK!

    View Slide

  46. View Slide

  47. xkcd.com/323

    View Slide

  48. View Slide

  49. The End

    View Slide

  50. THANK YOU FOR LISTENING!
    Questions? Ask me: @dzuelke & [email protected]

    View Slide