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

High Stakes Continuous Delivery in the Real World #OpenWest

High Stakes Continuous Delivery in the Real World #OpenWest

You have a robust set of tests and you're using a continuous integration server, so you feel great about your project. You're ready for the next step - continuous delivery. Automatically deploying your changes to production can be a scary prospect for many teams, but in this talk we'll look at some real world examples in high stakes situations where continuous delivery allows teams to move faster and have greater confidence in their code. We'll walk through a sample CI/CD setup used on a real-world PHP-based ecommerce site and show how you can use this setup for your projects.

Joshua Warren

May 07, 2015
Tweet

More Decks by Joshua Warren

Other Decks in Technology

Transcript

  1. High Stakes Continuous
    Delivery in the Real World
    Presented by Joshua Warren

    View full-size slide

  2. How I Learned To Stop
    Worrying and Love
    Deployments

    View full-size slide

  3. PHP Developer
    Working with PHP since 1999

    View full-size slide

  4. Founder & CEO
    Founded Creatuity in 2008
    PHP Development Firm
    Focused on the Magento platform
    Some of our developers, October ‘12

    View full-size slide

  5. Frequent Conference Presenter
    Occasional Open Source Contributor
    Over-Tweeter

    View full-size slide

  6. JoshuaWarren.com
    @JoshuaSWarren

    View full-size slide

  7. IMPORTANT!
    • joind.in/13900
    • Download slides
    • Post comments
    • Leave a rating!

    View full-size slide

  8. What’s That?
    CONTINUOUS DELIVERY

    View full-size slide

  9. –ContinuousDelivery.com
    “Releasing high quality software fast
    through build, test and deployment
    automation.”

    View full-size slide

  10. Testing + Automation
    Increases confidence in completed code
    Decreases delay between task completion
    & deployment

    View full-size slide

  11. #OpenWest
    Continuous delivery is a
    mindset, not a technology.

    View full-size slide

  12. Any code you commit may
    be released to customers at
    any point.

    View full-size slide

  13. Yes, any code you commit
    may be released to
    customers at any point.

    View full-size slide

  14. Commits made by Google’s
    Customer Surveys team are
    live in production in just 8
    minutes.

    View full-size slide

  15. Or: The Benefits of Continuous Delivery
    WHY WOULD YOU DO THAT?!

    View full-size slide

  16. Frequent feedback from end-users

    View full-size slide

  17. Business advantages - reduce time to market,
    react to changes faster

    View full-size slide

  18. Efficient
    Developers focus on developing, not deploying

    View full-size slide

  19. Or: How to Implement Continuous Delivery for PHP Projects
    OK, YOU’VE CONVINCED US…

    View full-size slide

  20. Prerequisites
    • Automated testing
    • Authority to change processes

    View full-size slide

  21. #OpenWest
    Make your workflow and process
    changes before beginning to
    implement a continuous delivery
    system.

    View full-size slide

  22. Change Your Workflow Today

    View full-size slide

  23. Our Workflow at Creatuity

    View full-size slide

  24. Each branch should be a self-contained new
    feature

    View full-size slide

  25. When work is complete on a branch, that branch
    must be completely ready to deploy

    View full-size slide

  26. Completed branch is tested by our continuous
    integration server

    View full-size slide

  27. Completed branch is tested by our QA team

    View full-size slide

  28. Branch is indicated as deploy-ready

    View full-size slide

  29. Branch is deployed to production

    View full-size slide

  30. CI Server
    • Bamboo, Jenkins or ? - choice is yours
    • Our examples will use Bamboo

    View full-size slide

  31. Bamboo Testing
    • Configure it to your liking
    • We use phing, phpunit, etc
    • Must define an artifact, but can be empty

    View full-size slide

  32. Bamboo Deployments
    • Create a deployment project
    • Define an environment - in our case, ‘Staging’
    • Attach it to your build plan used for testing

    View full-size slide

  33. Bamboo Environments
    • Environments are just labels
    • Environment-specific details will be stored
    elsewhere

    View full-size slide

  34. Bamboo Tasks
    • Tasks are where the magic happens
    • We use tasks to trigger our deployment system,
    rocketeer

    View full-size slide

  35. For now, it’s a magic box…
    What’s Rocketeer?

    View full-size slide

  36. But we’ll learn more in a bit…
    Yup, a magic box

    View full-size slide

  37. Rocketeer Check Task
    rocketeer check --on-staging -n

    View full-size slide

  38. Rocketeer Deploy Task
    rocketeer deploy —on-staging -n

    View full-size slide

  39. #OpenWest
    Four short tasks in Bamboo are all it
    takes to automate deploying your PHP
    projects.

    View full-size slide

  40. Bamboo Triggers
    Deploys are triggered on schedule or after every passing build

    View full-size slide

  41. Bamboo Notifications
    We trigger HipChat notification on every deploy start & finish

    View full-size slide

  42. Each Successful Build Results in an Automatic
    Deployment

    View full-size slide

  43. Deployments are reported to HipChat, appear on
    the deployment board in Bamboo

    View full-size slide

  44. JIRA Integration
    Include JIRA issue keys in your
    commit message

    View full-size slide

  45. #OpenWest
    Bamboo + Rocketeer takes us from
    passed test to deployment in less than
    half an hour with no manual steps.

    View full-size slide

  46. The magic behind our automatic deployments
    ROCKETEER

    View full-size slide

  47. Not That Rocketeer
    github.com/rocketeers/rocketeer
    rocketeer.autopergamene.eu

    View full-size slide

  48. Rocketeer is a modern PHP task runner and
    deployment package.

    View full-size slide

  49. Install Rocketeer
    wget http://rocketeer.autopergamene.eu/versions/rocketeer.phar
    chmod +x rocketeer.phar
    mv rocketeer.phar /usr/local/bin/rocketeer

    View full-size slide

  50. Configure Rocketeer
    cd
    rocketeer ignite

    View full-size slide

  51. Rocketeer adds a .rocketeer folder to your project
    Commit this folder

    View full-size slide

  52. Committing .rocketeer allows Bamboo plus
    anyone on your team to run deployments

    View full-size slide

  53. ‘rocketeer ignite’ will configure most of it’s files for you

    View full-size slide

  54. We’ll modify a few of the files for project-specific details

    View full-size slide

  55. Don’t worry…

    View full-size slide

  56. .rocketeer/config.php
    Edit host record if you’re using a non-standard SSH port

    View full-size slide

  57. .rocketeer/hooks.php
    • Add project-specific commands
    • We’ll add a few Magento-specific items

    View full-size slide

  58. .rocketeer/hooks.php
    'before' => [
    'setup' => [],
    'deploy' => array(
    'magerun sys:maintenance --on'
    ),
    'cleanup' => [],
    ],

    View full-size slide

  59. .rocketeer/hooks.php
    'after' => [
    'setup' => [],
    'deploy' => [],
    'cleanup' => array(
    'magerun sys:setup:run',
    'magerun cache:clean',
    'magerun cache:flush',
    'magerun index:reindex:all',
    'magerun sys:maintenance --off',
    ),
    ],

    View full-size slide

  60. .rocketeer/remote.php
    'shared' => [
    'media',
    'var',
    'app/etc/local.xml',
    ],

    View full-size slide

  61. .rocketeer/strategies.php
    return $composer->install([], ['--no-interaction' => null, ’--no-dev'
    => null, '--prefer-dist' => null, '--no-plugins' => null]);

    View full-size slide

  62. Next Up
    • Commit these changes to your Rocketeer files
    • Prepare your server to receive the deployment

    View full-size slide

  63. Server File Structure
    • current
    • releases
    • shared

    View full-size slide

  64. File Structure
    • current and releases are managed by Rocketeer
    • shared contains folders shared by each release

    View full-size slide

  65. Magento Shared Files
    • app/etc/local.xml
    • media
    • var

    View full-size slide

  66. Rocketeer Folder Structure
    • Rocketeer deploys to a new folder under
    releases
    • Updates symlinks to shared folder
    • Then updates current symlink to new release

    View full-size slide

  67. Rocketeer Prep
    • Make sure SSH keys are setup correctly
    • Rocketeer will connect to your SSH repo via your
    server - before running deploy for the first time,
    test your SSH setup

    View full-size slide

  68. SSH config file
    Host yourGitServer.example
    HostName yourGitServer.example
    IdentityFile ~/.ssh/your_public_key_rsa
    IdentitiesOnly yes

    View full-size slide

  69. Rocketeer Prep
    • rocketeer check
    • rocketeer deploy —pretend
    • That’s it - you’re ready to deploy!

    View full-size slide

  70. Or: What’s Next?
    WHERE DO WE GO FROM
    HERE?

    View full-size slide

  71. Advanced Rocketeering
    • Custom tasks
    • Listening to events, firing events
    • Task builder
    • Task queues

    View full-size slide

  72. Feature Toggles
    • First step of implementing a new feature - wrap it
    in a feature toggle
    • Code only executes if feature is enabled
    • Enables deploying new code immediately

    View full-size slide

  73. Canaries
    • Deploy to a small portion of your site’s traffic
    • Compare error rates between new & old version
    • If error rate is same or lower, deploy globally

    View full-size slide

  74. Don’t get distracted by these advanced concepts -
    start by moving to basic continuous delivery first.

    View full-size slide

  75. Keep In Touch!
    • joind.in/13900
    • @JoshuaSWarren
    • JoshuaWarren.com

    View full-size slide