Slide 1

Slide 1 text

Cloud Computing-Based Service Design and Programming Andy Kuo @andikan Deployment and Others

Slide 2

Slide 2 text

➡ Trello ➡ User Authentication ➡ Heroku ➡ MongoLab ➡ Files Upload to S3 ➡ Github Page

Slide 3

Slide 3 text

https://trello.com/

Slide 4

Slide 4 text

Kanban Board

Slide 5

Slide 5 text

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/

Slide 6

Slide 6 text

Passport.js Simple, unobtrusive authentication for Node.js $ npm install passport http://passportjs.org/

Slide 7

Slide 7 text

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/

Slide 8

Slide 8 text

Runing Node.js App on Heroku https://www.heroku.com/ Heroku

Slide 9

Slide 9 text

SaaS PaaS IaaS Software as a Service Platform as a Service Infrastructure as a Service

Slide 10

Slide 10 text

FTP http://www.slideshare.net/lkiral/git-34157836 Using Git push

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Getting Started with Node.js on Heroku https://devcenter.heroku.com/articles/getting-started-with-nodejs

Slide 15

Slide 15 text

Heroku user account Signup is free ! https://signup.heroku.com/signup/dc step0

Slide 16

Slide 16 text

Install Heroku Toolbelt Heroku command line tool https://toolbelt.heroku.com/ step0

Slide 17

Slide 17 text

Login Heroku $ heroku login You can login in any directory step1

Slide 18

Slide 18 text

Declare process type with Procfile web: node app.js Declare the command to start a web dyno step2

Slide 19

Slide 19 text

Start your app locally using Foreman $ foreman start Try using foreman to run your server locally step3

Slide 20

Slide 20 text

Store in Git $ git init $ git add . $ git commit -m “commit message” step4

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

Ensure the dyno $ heroku ps:scale web=1 Ensure we have one dyno running the web process type step7

Slide 25

Slide 25 text

Check state of dynos $ heroku ps List the running dynos of your application step8

Slide 26

Slide 26 text

Visit your app $ heroku open Visit the app in the browser step9

Slide 27

Slide 27 text

View the logs $ heroku logs $ heroku logs -n 200 Heroku only stores the last 1500 lines of log history

Slide 28

Slide 28 text

Server console $ heroku run node This console has nothing loaded other than the Node.js standard library

Slide 29

Slide 29 text

Habits of a Happy Node Hacker https://blog.heroku.com/archives/2014/3/11/node-habits

Slide 30

Slide 30 text

Keep dependencies out of source control $ echo node_modules >> .gitignore Ignoring the node_modules directory using git ignore

Slide 31

Slide 31 text

Keep track of outdated dependencies $ npm outdated Figure out which of your app’s dependencies have fallen behind and need to be updated

Slide 32

Slide 32 text

Staging Server ?

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

MongoLab https://mongolab.com/

Slide 35

Slide 35 text

DaaS Database as a Service MongoDB hosting platform Hosting on Amazon, Google, Rackspace, Windows Azure Automated backups, web-based tools, monitoring and support

Slide 36

Slide 36 text

Heroku Add-ons Add powerful functionality to your apps with ease https://addons.heroku.com/

Slide 37

Slide 37 text

https://addons.heroku.com/

Slide 38

Slide 38 text

Using Heroku MongoLab Add-on $ heroku addons: add mongolab By default, add free Sandbox plan

Slide 39

Slide 39 text

Get MongoLab connection URI $ heroku config | grep MONGOLAB_URI The connection URI to connect to MongoDB hosting on the MongoLab

Slide 40

Slide 40 text

Connect to MongoLab URI

Slide 41

Slide 41 text

Connect to MongoLab URI

Slide 42

Slide 42 text

MongoLab’s admin GUI for MongoDB $ heroku addons:open mongolab

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Files upload to Heroku

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

Amazon S3 bucket Create a AWS account Create a S3 bucket Edit S3 bucket permission property

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

Uploading directly to Amazon S3 https://devcenter.heroku.com/articles/s3-upload-node https://github.com/d1b1/heroku-nodejs-s3-demo

Slide 50

Slide 50 text

https://www.inkfilepicker.com/ https://addons.heroku.com/filepicker https://devcenter.heroku.com/articles/filepicker

Slide 51

Slide 51 text

Github Pages

Slide 52

Slide 52 text

Github Pages Hosted directly from your Github repository User or organization page / Project page https://pages.github.com/

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

Socket.io http://socket.io/

Slide 56

Slide 56 text

Socket.io $ npm install socket.io http://socket.io/#how-to-use

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

Redis http://redis.io/

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

Kue $ npm install kue Delayed jobs Jobs priority https://github.com/learnboost/kue http://learnboost.github.io/kue/

Slide 61

Slide 61 text

Redis Pub/Sub Publish and Subscribe to the channel https://github.com/louischatriot/node-redis-pubsub http://redis.io/topics/pubsub

Slide 62

Slide 62 text

Cloud Computing-Based Service Design and Programming Andy Kuo @andikan Thanks