WordCamp Belfast DevOps for Beginners

53
WordPress DevOps For Beginners http://poweredbycoee.co.uk Stewart Ritchie @stewartritchie stewart@poweredbycoee.co.uk

Transcript of WordCamp Belfast DevOps for Beginners

Page 1: WordCamp Belfast DevOps for Beginners

WordPress DevOps For Beginners

http://poweredbycoffee.co.uk

Stewart Ritchie

@stewartritchie [email protected]

Page 2: WordCamp Belfast DevOps for Beginners

This is NOT a Tutorial

http://poweredbycoffee.co.uk

This is a guide to dev ops for beginners. You’ve probably heard talks about this stuff before. aimed at technical tutorial instead of a 101 - why should you care

This talk is for - beginners to devops, - devs who want to start to improve their productivity and quality- business owners who hear developers talking about stuff the don't understand and want to up their understanding- pm’s who want more control and efficiency

Page 3: WordCamp Belfast DevOps for Beginners

What is Dev Ops anyway?

http://poweredbycoffee.co.uk

Asked my friends Andy, works for Sky on Now TV as a Scrum Master

Dev Ops is a very simple concept at its heart.

Its not a technology.its not a cure all to your problems.

Investment. Spent time now - create development project processes - that save time later- improve efficiency - improve happiness- and improve your over all project outcome. (Quality/Time to market/Profitability)

IE - Devs spend more time developing.

Page 4: WordCamp Belfast DevOps for Beginners

Why is Dev Ops Important?

http://poweredbycoffee.co.uk

why does it provide value? no value - no point1. dev2. bus3. comm

Page 5: WordCamp Belfast DevOps for Beginners

1. DevOps will make you a better developer.

http://poweredbycoffee.co.uk

- You’ll learn to structure your code in more reusable, - your learn how do write code that can be tested- you’ll learn to think about performance and failure of the code you write

1. collaborate with other developers2. reduce the risk of trying new techniques3. improve the quality of your code4. Help developers do more development and less system administration5. bring new people into a project quickly.

Page 6: WordCamp Belfast DevOps for Beginners

2. DevOps will help you deliver better work to your clients

http://poweredbycoffee.co.uk

You will be able to deliver faster, iterate faster, involve your clients in your process more.Talk about deployments/Continuous Integration

-Make it hard or almost impossible to have a bug get in production1. If you do have a problem, your recovery time will be slashed.2. Make everyone on your team more efficient 3. faster iteration cycle4. better data mining and monitoring of systems

Page 7: WordCamp Belfast DevOps for Beginners

3. DevOps helps move WordPress into bigger companies and opportunities

http://poweredbycoffee.co.uk

DevOps bring reliability, repeatability and lowers risk.

WordPress == Wild West - a toy/hobby. DevOps brings respectability.

scaleabilityreliabilitypredicable and repeatable

Page 8: WordCamp Belfast DevOps for Beginners

How Does Dev Ops Help?

http://poweredbycoffee.co.uk

1. Collaboration

2. Code Sharing

3. Automation

Page 9: WordCamp Belfast DevOps for Beginners

1. Collaboration

http://poweredbycoffee.co.uk

Work together better.

teams grow,projects grow, more and more people will need involvedBad collaboration can kill projects deadDeveloper collaboration is hard

Page 10: WordCamp Belfast DevOps for Beginners

Version Control

http://poweredbycoffee.co.uk

Easy for developers to collaborate

A hardened nuclear bunker for your source code

Makes it easy to have more that one version of your project!

Basically a time machine

- version control - gives us a way to manage code and version that gets it off your laptop - code is a shared resource and changes should not be made 'willy nilly" - similar to version on the mac or even time machine you can go back in time to a point in your project

Page 11: WordCamp Belfast DevOps for Beginners

What is a “Commit”?

http://poweredbycoffee.co.uk

- Snapshot of code- the difference since the last snapshot, layer them up and you get a project

- a commit should include a defined piece of work - bug fix - a change that had a purpose - made changes that you dont want to keep? revet to the last commit.

Page 12: WordCamp Belfast DevOps for Beginners

http://poweredbycoffee.co.uk

This layering gives us a log of the project over timeSee how files changed

Page 13: WordCamp Belfast DevOps for Beginners

Merging Version Control

http://poweredbycoffee.co.uk

- Gives you the ability to manage different versions of your software

- Development, Staging & Production

- Approve code to move up the versions into production

The real killer feature is that your code base can exits in different states. This comes from “Branching”1. you can see here every dot is a commit. 2. At this commit you made a deployement3. you keep commiting until some one finds a bug - you;ve been working on the project in the mean time, added half a dozen unfinished features you fix the bug in your

deployed version. Now you need to unpick the new features or download

Page 14: WordCamp Belfast DevOps for Beginners

http://poweredbycoffee.co.uk

Page 15: WordCamp Belfast DevOps for Beginners

http://poweredbycoffee.co.uk

Page 16: WordCamp Belfast DevOps for Beginners

http://poweredbycoffee.co.uk

Page 17: WordCamp Belfast DevOps for Beginners

http://poweredbycoffee.co.uk

Page 18: WordCamp Belfast DevOps for Beginners

http://poweredbycoffee.co.uk

Page 19: WordCamp Belfast DevOps for Beginners

2. Code Sharing

http://poweredbycoffee.co.uk

all projects have code that they didn’t create in them

Page 20: WordCamp Belfast DevOps for Beginners

Dependencies

http://poweredbycoffee.co.uk

- every software project is built on the shoulders of those that came before it. - starting fro scratch again would be irresponsible and wasteful- PHP is a dependency (basically a piece of software written in C), mysql and a webserver- we do not want to have to manage code we didn’t create, do not commit that- multiple kinds of dependencies to manage (production/dev) software

Page 21: WordCamp Belfast DevOps for Beginners

WordPress Has Dependencies

http://poweredbycoffee.co.uk

- Diff by Geoffrey T. Bairiki

- ID3 by James Heinrich

- BackBone & Underscores

Page 22: WordCamp Belfast DevOps for Beginners

The Problem with dependancies is that they can change

http://poweredbycoffee.co.uk

- The problem with dependancies is that they change - Writing software is hard, using extenal dependancies is hard. - they change. Features get added or removed - Building a house with a foundation of sand - the sand/dependency changes and the house can fall down - by targeting a specific version of a library or a dependancy you can stop this happening - then update when you know its safe (SEMVER - FTW) - dependencies can have their own dependencies

Page 23: WordCamp Belfast DevOps for Beginners

What About Your Project?

http://poweredbycoffee.co.uk

- WordPress is a dependancy. Its a library that your are writing software against - So are all your plugins, themes, libraries etc etc - any libraries you add are dependencies (PHP/JS/CSS) - You are creating something that depends on these - that is a risk

Page 24: WordCamp Belfast DevOps for Beginners

Your Dependancies - have dependencies

http://poweredbycoffee.co.uk

- WordPress is a dependancy. Its a library that your are writing software against - So are all your plugins, themes, libraries etc etc - any libraries you add are dependencies (PHP/JS/CSS) - You are creating something that depends on these - that is a risk

- Different kinds of dependencies - production dependencies - stuff needed to make the site run - dev dependencies - helpers and devtool

Page 25: WordCamp Belfast DevOps for Beginners

What About Your Project?

http://poweredbycoffee.co.uk

- Story of Smallbusiness.co.uk - using Timber (with routing) - timber goes v1 all fine - timber goes v1.1 site falls apart - routing was removed - wordpress updates to 4.6 and falls apart - dependencies to blame - installed routes -> installed wpcli -> requests - requests got included in wp 4.6 hence a conflict - site collapses

Page 26: WordCamp Belfast DevOps for Beginners

This Sounds Like a Nightmare

http://poweredbycoffee.co.uk

- managing all this manually shounds like a nightmare - install the librarys/whatever you tell it to in the version you tell it to - install all the things you need to run that thing as well. And the correct versions for it. - This is pretty cool - keeps your team using the same things - recorded in a file so you dont have to store them in your repo

You’ve probably already done something similar installing grunt/gulp/sass etc

Page 27: WordCamp Belfast DevOps for Beginners

getcomposer.org

- composer - composer.json - WordPress and composer are not natural friends - we need to move everything that might change in our repo out of the wordpress folder - htaccess - wp-config.php - wp-content - many good tutorials on the web for this - configure composer to work - get plugins and themes from github, packaginst and wp-packagist - satispress for premium plugins - wordpress maybe becoming a package - composer.json trac ticket

Page 28: WordCamp Belfast DevOps for Beginners

- get plugins and themes from github, packaginst and wp-packagist

Page 29: WordCamp Belfast DevOps for Beginners

- satispress for premium plugins

Page 30: WordCamp Belfast DevOps for Beginners

Composer & WordPress

http://poweredbycoffee.co.uk

https://core.trac.wordpress.org/ticket/23912

https://core.trac.wordpress.org/ticket/36335

WordPress may be becoming a composer package

Page 31: WordCamp Belfast DevOps for Beginners

bower.io

- bower for JS - much simpler - load JS however you want

Page 32: WordCamp Belfast DevOps for Beginners

Can Bite You

http://poweredbycoffee.co.uk

LeftPad

Cache stuff, mirror critical dependancies

Page 33: WordCamp Belfast DevOps for Beginners

Easy Ways To Get Started

http://poweredbycoffee.co.uk

- write stuff as small plugins - version control the plugin and use your repeats in projects - eg - wpmail-mailgun - envswitch - disable xmlrpc - google analytics

Page 34: WordCamp Belfast DevOps for Beginners

3. Automation

http://poweredbycoffee.co.uk

Page 35: WordCamp Belfast DevOps for Beginners

Repetition Sucks

http://poweredbycoffee.co.uk

Mistakes Get Made

People Get Bored

Creative people usually don't like to do the same thing over and over again.

Not a good use of skills and talent

anything that has to be done regularly and takes more than 2 minutes is a good candidate

Page 36: WordCamp Belfast DevOps for Beginners

Need to do it twice?

http://poweredbycoffee.co.uk

Page 37: WordCamp Belfast DevOps for Beginners

Need to do it twice?

Automate it.

http://poweredbycoffee.co.uk

Page 38: WordCamp Belfast DevOps for Beginners

Good Candidates for Automation

http://poweredbycoffee.co.uk

Deployments

Compiling Assets (Sass, CoffeeScript, etc)

Compressing Images

Setting up servers

Installing WordPress

Introduce myself (who I am, what I do)

Introduce the topic - imposter syndrome - creativity in churches - anger and identity

We need to ask a few questions?

Page 39: WordCamp Belfast DevOps for Beginners

I Hate FTP

http://poweredbycoffee.co.uk

- slow, insecure, inaccurate- who has had a site stop working because a file didn't transfer properly over FTP?- initial deploy is slow (huge sites)- updates are slow and error prone- enables bad behaviour and "cowboy coding"

Page 40: WordCamp Belfast DevOps for Beginners

Automated Deployments

http://poweredbycoffee.co.uk

No more slow or failed FTP transfers

Easily tied into your version control

Easily undo a mistake

Get new code into production with a few key stokes or clicks

- faster- use your version control backend- provide an audit trail- can be automated and customised to suit how your team works- version control branches and deployments- allows us to give clients visual updates super fast without having to code on the server

Page 41: WordCamp Belfast DevOps for Beginners

http://capistranorb.com

Introduce myself (who I am, what I do)

Introduce the topic - imposter syndrome - creativity in churches - anger and identity

We need to ask a few questions?

Page 42: WordCamp Belfast DevOps for Beginners

Capistrano

http://poweredbycoffee.co.uk

- Scriptable and self-installed

- Ruby

- Task Based

- Logs in to your server, pulls from your Version Control, runs a series of tasks

you tell it to.

- Super powerful and flexible

- ssh, git pull, run tasks - has role backs, supports multiple servers and roles. - Ruby /shrug - FREE & OpenSource - cap staging deploy - capistrano logs in to seach server and does a git pull - runs and tasks we tell in to eg `composer install` - then creates symlinks for any directories that are shared between releases - run any other tasks we might wants as well (eg assets/image compression etc)

Page 43: WordCamp Belfast DevOps for Beginners

Deploy HQ Deploy Bot Buddy

Introduce myself (who I am, what I do)

Introduce the topic - imposter syndrome - creativity in churches - anger and identity

We need to ask a few questions?

Page 44: WordCamp Belfast DevOps for Beginners

DeployBot (etc)

http://poweredbycoffee.co.uk

- Many of these services exist

- Hard to configure but just works when its done

- $/£/€

- Less control and less flexible but easier to setup

- logins via ssh - has a record of the last commit you deployed - git pulls onto their server - then transfers every files that has been modified since the last deployment

Page 45: WordCamp Belfast DevOps for Beginners

Standardising Environments

http://poweredbycoffee.co.uk

- this seems to create massive complexity - massively not worth it - riiiight up until it save you. - different versions of MySQL and PHP have different features - some of thee things are easy to change, some not - make it impossible to have a problem - pick one a build against it - utf8mb4 and MySQL < 5.5.3 - if you develop on one the try to move into production on another - you have a problem - PHP versions

Page 46: WordCamp Belfast DevOps for Beginners

Use Virtual Machines

http://poweredbycoffee.co.uk

- Virtual Machienes (Parallels etc)

Page 47: WordCamp Belfast DevOps for Beginners

vagrantup.com

not that cleverCLI interface and automation tool for VirtualBoxBecause no one wants to use virtual box

Page 48: WordCamp Belfast DevOps for Beginners
Page 49: WordCamp Belfast DevOps for Beginners

Concluding

http://poweredbycoffee.co.uk

Page 50: WordCamp Belfast DevOps for Beginners

Its going to take a while

http://poweredbycoffee.co.uk

Page 51: WordCamp Belfast DevOps for Beginners

These aren’t WordPress Skills

http://poweredbycoffee.co.uk

Page 52: WordCamp Belfast DevOps for Beginners

They are Professional Development Skills

http://poweredbycoffee.co.uk

Page 53: WordCamp Belfast DevOps for Beginners

Where To Go Next?

http://poweredbycoffee.co.uk

- Automated Testing (Never ship something broken again)

- Visual Regression Testing (Make CSS changes less painful)

- Code Quality Checks (Stop bad code getting into your repo or near a server)

- Install Software on your servers with a few keystrokes

- Notifications and Integration with your other tools