Top Banner
Deploy like a Pro Damián Serrano Thode @dsthode MalagaMakers GeekBeers (20150115)
39
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Deploy like a pro!

Deploy like a Pro

Damián Serrano Thode

@dsthode

MalagaMakers GeekBeers (20150115)

Page 2: Deploy like a pro!

What is deployment?

Page 3: Deploy like a pro!

Copy source files to the server

What is deployment?

Page 4: Deploy like a pro!
Page 5: Deploy like a pro!

Copy source files to the server

Not just that!

What is deployment?

Page 6: Deploy like a pro!

✔ Optimize assets

What is deployment?

Page 7: Deploy like a pro!

✔ Optimize assets✔ Run database migrations

What is deployment?

Page 8: Deploy like a pro!

✔ Optimize assets✔ Run database migrations

✔ Restart dependent services

What is deployment?

Page 9: Deploy like a pro!

✔ Optimize assets✔ Run database migrations

✔ Restart dependent services

Provide rollback functionality

What is deployment?

Page 10: Deploy like a pro!
Page 11: Deploy like a pro!

Optimize assets

Page 12: Deploy like a pro!

Optimize assetsEnter Grunt → http://gruntjs.com

Page 13: Deploy like a pro!

Optimize assets

Combine and minify javascript

Page 14: Deploy like a pro!

Optimize assetsCombine and minify javascript

You can use grunt-contrib-uglify

Page 15: Deploy like a pro!

Optimize assets

Preprocess, combine and minify styles

Page 16: Deploy like a pro!

Optimize assetsPreprocess, combine and minify styles

You can use grunt-contrib-sass & grunt-contrib-cssmin

Page 17: Deploy like a pro!

Optimize assets

Optimize and combine images

Page 18: Deploy like a pro!

Optimize assetsOptimize and combine images

You can use grunt-spritesmith &grunt-contrib-imagemin

Page 19: Deploy like a pro!

Optimize assets

Optimize and combine font files (SVG only)

Page 20: Deploy like a pro!

Optimize assetsOptimize and combine font files (SVG only)

You can use the same grunt-contrib-imagemin

Page 21: Deploy like a pro!

Database migrations,

deployment & rollback

Page 22: Deploy like a pro!

Enter Capistrano → http://capistranorb.com

Page 23: Deploy like a pro!

“A remote server automation and deployment tool written in Ruby.”

“Capistrano is written in Ruby, but it can easily be used to deploy any language.”

Page 24: Deploy like a pro!

Run “cap install” on your project folder

Page 25: Deploy like a pro!

Capfile defines requirements for your deployment tasks→

config/deploy.rb shared configuration for all the stages→

config/deploy/*.rb defines multiple stage deployment→

lib/capistrano/tasks where your custom tasks are defined→

Page 26: Deploy like a pro!

Lots of tasks off-the-shelf that integrate with the Ruby on Rails framework

bundler, assets, migrations, Passenger, etc...

You just need to include the gems in your Gemfile and uncomment the require in the Capfile

Page 27: Deploy like a pro!

Sample Capfile

Page 28: Deploy like a pro!

Sample config/deploy.rb

Page 29: Deploy like a pro!

Sample config/deploy/production.rb

Page 30: Deploy like a pro!

Different roles available:

app, web, db

Also, you can define several servers at once, eg:

Page 31: Deploy like a pro!

Available tasks

Page 32: Deploy like a pro!

Deployment

Run 'cap <stage> deploy' on your console

Page 33: Deploy like a pro!

Deployment flow

Page 34: Deploy like a pro!

Rollback

Run 'cap <stage> deploy:rollback' on your console

Page 35: Deploy like a pro!

Rollback flow

Page 36: Deploy like a pro!

You can attach to any step to run custom commands using 'before' and 'after' from Capistrano DSL, eg:

Page 37: Deploy like a pro!

Not a Rails shop?

You might need manual work creating your recipes,although there is some hope in certain cases:

capistrano-node-deploy Node.js apps→capistrano-virtualenv virtualenv python apps→

capistrano-django Django apps→capistrano-go Go apps →

Caveat emptor! Might be old, untested or unsuitable

Page 38: Deploy like a pro!

Where to go from here?

Infrastructure management tools like Chef or Puppet for server provisioning

Continuous integration hooks for automated deployment to staging servers

Page 39: Deploy like a pro!

Talk deployedQuestions?

Damián Serrano Thode

@dsthode

MalagaMakers GeekBeers (20150115)