Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Deployment and Others Tutorial

Deployment and Others Tutorial

2014/05/15 @ NTU CCSP

andikan

May 15, 2014
Tweet

More Decks by andikan

Other Decks in Programming

Transcript

  1. More about Trello • Introductions - http://blog.fogcreek.com/how-we-make-trello/ - http://csswizardry.com/2014/05/my-trello-workflow/ •

    Trello Tech Stack - http://blog.fogcreek.com/the-trello-tech-stack/ • Node.js wrapper for Trello’s API - https://github.com/adunkman/node-trello • Phaser app : simple kanban board - http://phaserapp.com/
  2. Passport.js Single Sign-on using an OAuth provider such as Facebook

    Token-based credentials to protect access $ npm install passport-facebook http://passportjs.org/guide/facebook/
  3. SaaS PaaS IaaS Software as a Service Platform as a

    Service Infrastructure as a Service
  4. Cedar The celadon cedar stack Default runtime stack and is

    a flexible, polyglot environment https://devcenter.heroku.com/articles/stack https://devcenter.heroku.com/articles/cedar
  5. Dyno A lightweight container running a single user-specified command Web

    processes, worker processes and any process types declared in the app’s Procfile https://devcenter.heroku.com/articles/dynos
  6. Procfile What commands are run by your app’s dyno on

    the Heroku A text file named Procfile web: node app.js https://devcenter.heroku.com/articles/procfile
  7. Start your app locally using Foreman $ foreman start Try

    using foreman to run your server locally step3
  8. Store in Git $ git init $ git add .

    $ git commit -m “commit message” step4
  9. Create a Heroku app $ heroku create $ heroku create

    your-app-name Automatically add a git remote named “heroku” pointing at your Heroku app remote git repository URL $ git remote -v step5
  10. Deploy your code $ git push heroku master After Heroku

    detects Node.js app and install dependencies with npm, it will launch the process declared in Procfile step6
  11. Ensure the dyno $ heroku ps:scale web=1 Ensure we have

    one dyno running the web process type step7
  12. Check state of dynos $ heroku ps List the running

    dynos of your application step8
  13. View the logs $ heroku logs $ heroku logs -n

    200 Heroku only stores the last 1500 lines of log history
  14. Server console $ heroku run node This console has nothing

    loaded other than the Node.js standard library
  15. Keep dependencies out of source control $ echo node_modules >>

    .gitignore Ignoring the node_modules directory using git ignore
  16. Keep track of outdated dependencies $ npm outdated Figure out

    which of your app’s dependencies have fallen behind and need to be updated
  17. Development Staging Production Environments This environment runs virtually identical to

    production, but on a backup of the production database Developing and run the local server This environment run for real users
  18. DaaS Database as a Service MongoDB hosting platform Hosting on

    Amazon, Google, Rackspace, Windows Azure Automated backups, web-based tools, monitoring and support
  19. Get MongoLab connection URI $ heroku config | grep MONGOLAB_URI

    The connection URI to connect to MongoDB hosting on the MongoLab
  20. Uploaded Files on Heroku are lost ? Each time you

    push a new change to your Heroku application, your application is recreated and all uploaded data in /public directory is lost
  21. Uploading directly to Amazon S3 Each time you push a

    new change to your Heroku application, your application is recreated and all uploaded data in /public directory is lost
  22. Amazon S3 bucket Create a AWS account Create a S3

    bucket Edit S3 bucket permission property
  23. Setup AWS credentials in Heroku $ heroku config:set AWS_ACCESS_KEY_ID=xxx $

    heroku config:set AWS_SECRET_ACCESS_KEY=yyy $ heroku config:set S3_BUCKET=zzz
  24. Github Pages Hosted directly from your Github repository User or

    organization page / Project page https://pages.github.com/
  25. Creating Project Pages $ git checkout --orphan gh-pages create a

    branch named ‘gh-pages’ without any parents $ git rm -rf . https://help.github.com/articles/creating-project-pages-manually
  26. Creating Project Pages create index.html file $ git add index.html

    $ git commit -am “First pages commit” $ git push origin gh-pages username.github.io/projectname https://help.github.com/articles/creating-project-pages-manually
  27. Using Heroku Redis To Go Add-on $ heroku addons: add

    redistogo https://devcenter.heroku.com/articles/redistogo#using-with-node-js https://addons.heroku.com/redistogo