+ All Categories
Home > Technology > Rock-solid Magento Deployments (and Development)

Rock-solid Magento Deployments (and Development)

Date post: 02-Jul-2015
Category:
Upload: aoe
View: 5,082 times
Download: 3 times
Share this document with a friend
Description:
In this session we show how to organize Magento projects using Version control and how to have a full development and deployment process in place to assure highest quality with many developers involved and teams spread over different continents. This talk covers how to run a continuous integration pipeline that takes care of testing various aspects of the webshop (unit tests, acceptance tests, performance test,…). Covers: Continuous integration, automation, Vagrant/Chef, Testing pipeline, unit/acceptance/performance tests, monitoring, deployment workflows, development best practices
113
Magento Deployments Rock-Solid …and Development php[world] 2014 Washington D.C.
Transcript
Page 1: Rock-solid Magento Deployments (and Development)

Magento Deployments Rock-Solid

…and Development

php[world] 2014 – Washington D.C.

Page 2: Rock-solid Magento Deployments (and Development)

Fabrizio Branca

Page 3: Rock-solid Magento Deployments (and Development)

fbrnc

fbrnc

Page 4: Rock-solid Magento Deployments (and Development)
Page 5: Rock-solid Magento Deployments (and Development)

E-Commerce: Magento

CMS: TYPO3

Portals: ZF, FLOW,…

Mobile Searchperience: SOLR

>120 people world-wide

High Performance

/Scale

Global Enterprise Projects

Page 6: Rock-solid Magento Deployments (and Development)

San Francisco, CA

Janine

Fiona

that’s me

Leo

Page 7: Rock-solid Magento Deployments (and Development)
Page 8: Rock-solid Magento Deployments (and Development)

Who’s a Magento developer? Who spends a significant

amount of his/her time dealing

with development/deployment

processes?

Who thinks he/she’s got it

figured out?

YOU...?

Page 9: Rock-solid Magento Deployments (and Development)

Picture The BIG

Page 10: Rock-solid Magento Deployments (and Development)

plan

code build

test

deploy operate

Page 11: Rock-solid Magento Deployments (and Development)

time

complexity

This is when we “deployed” using

a FTP client

Page 12: Rock-solid Magento Deployments (and Development)

Keep it simple!

Page 13: Rock-solid Magento Deployments (and Development)

http://xkcd.com/974/

Page 14: Rock-solid Magento Deployments (and Development)

You ain’t gonna need it!

Page 15: Rock-solid Magento Deployments (and Development)
Page 16: Rock-solid Magento Deployments (and Development)

code

Page 17: Rock-solid Magento Deployments (and Development)

Vocabulary

Page 18: Rock-solid Magento Deployments (and Development)

CMS

Magento

Solr

ERP

Project

Applications

Magento Magento

117

Magento

118

Magento

119

Builds

Release

Page 19: Rock-solid Magento Deployments (and Development)

Staging

Magento

72

Magento

103

Magento

119

Magento

72

Magento

103

Magento

119

Magento

72

Magento

103

Magento

119

Environment

Servers

Instances

Page 20: Rock-solid Magento Deployments (and Development)

Staging Integration Devbox Production Deploy

transient, potentially broken

Page 21: Rock-solid Magento Deployments (and Development)

Staging Integration Devbox Production Deploy

VirtualBox + Vagrant

Jenkins Server

identical setup

Page 22: Rock-solid Magento Deployments (and Development)

Build Package

Application System Storage

User Data

media directory (sometimes minified)

Database dump

Magento core

Modules

Scripts

Settings

Tools

Page 23: Rock-solid Magento Deployments (and Development)

Structure Project

Page 24: Rock-solid Magento Deployments (and Development)

project web root root !=

This is the complete project

This is where your webserver points to.

Page 25: Rock-solid Magento Deployments (and Development)

project web root root

Page 26: Rock-solid Magento Deployments (and Development)

htdocs

<Name>

<theme>

layout

template

code

design

etc

locale

<area>

core

community

local

<area>

<language>

modules

<package>

<Namespace>

<package>

*.xml

*.csv

<theme>

app

skin

lib

Structure Magento

Page 27: Rock-solid Magento Deployments (and Development)

htdocs

<Name>

<theme>

layout

template

code

design

etc

locale

<area>

core

community

local

<area>

<language>

modules

<package>

<Namespace>

<package>

*.xml

*.csv

<theme>

app

skin

lib

Module2

default

layout

template

code

design

etc

locale

frontend

local

frontend

de_DE

modules

base

My

base

My_Module2.xml

My_Module2.csv

default

app

skin

etc, Block, …

js, css, img, …

my_module2

my_module2

Magento My_Module My_Module2

Module

default

layout

template

code

design

etc

locale

frontend

local

frontend

de_DE

modules

base

My

base

My_Module.xml

My_Module.csv

default

app

skin

etc, Block, …

js, css, img, …

my_module

my_module

Page 28: Rock-solid Magento Deployments (and Development)

htdocs

Module

default

layout

template

code

design

etc

locale

local

frontend

de_DE

modules

My

base

*.xml

app

My_Module2.xml

My_Module2.csv

my_module2

My_Module.xml

My_Module.csv

etc, Block, …

my_module

Module2

etc, Block, …

my_module2

my_module

Page 29: Rock-solid Magento Deployments (and Development)

modman

by @colinmollenhour

Page 30: Rock-solid Magento Deployments (and Development)

htdocs

code

core

community

local

app

app/code/…/My/Module

.modman

My_Module

app/design/…

skin/frontend/…

app/etc/modules/My_Module.xml

modman

app/code/…/My/Module

My_Module2

app/design/…

skin/frontend/…

app/etc/modules/My_Module.xml

modman

<theme>

layout

template

design

etc

locale

<area>

<area>

<language>

modules

<package>

<package>

*.xml

*.csv

<theme>

skin

modman doesn’t even need to be in the web root!

Page 31: Rock-solid Magento Deployments (and Development)

Vanilla Magento

absolutely no core hacks!

…and core bugs you’ve fixed (and submitted to

Magento, of course…)

(except official patches)

Page 32: Rock-solid Magento Deployments (and Development)

“wiring” Intro

modman “connects” existing modules to the Magento core, but how do we manage them?

Page 33: Rock-solid Magento Deployments (and Development)

htdocs

code

core

community

local

app

app/code/…/My/Module

.modman

My_Module

app/design/…

skin/frontend/…

app/etc/modules/My_Module.xml

modman

app/code/…/My/Module

My_Module2

app/design/…

skin/frontend/…

app/etc/modules/My_Module.xml

modman

<theme>

layout

template

design

etc

locale

<area>

<area>

<language>

modules

<package>

<package>

*.xml

*.csv

<theme>

skin

Components

tools

n98-magerun.phar

phpunit.phar

modman

EnvSettingsTool

composer.phar

htdocs

.modman

Configuration

Installer

(Metadata, Doc,…)

My_Module

My_Module2

app,…

and usually there’s even more stuff…

These should come from different origins

Page 34: Rock-solid Magento Deployments (and Development)

Composer

Page 35: Rock-solid Magento Deployments (and Development)

magento-hackathon/ magento-composer-installer

Composer

Page 36: Rock-solid Magento Deployments (and Development)

AOEpeople/composer-installers "replace": { "magento-hackathon/magento-composer-installer":"*" }

“inspired” by composer/installers

“magento-module” “magento-source”

handles package types

Page 37: Rock-solid Magento Deployments (and Development)

<?php namespace Aoepeople\ComposerInstallers; class MagentoInstaller extends BaseInstaller { protected $locations = array( 'module' => '.modman/{$name}/', 'source' => 'htdocs/' ); }

AOEpeople/composer-installers

Page 38: Rock-solid Magento Deployments (and Development)

• Fully compatible with magento-hackathon/magento-composer-installer

• Adds support for type “magento-source”

• Only puts packages into place

• Native modman script is used to deploy modules

• Wrapped in a simple installer script

AOEpeople/composer-installers

Page 39: Rock-solid Magento Deployments (and Development)

{ "minimum-stability":"dev", "require":{ "aoepeople/composer-installers": "*", "fbrnc/aoe_scheduler": "*", "fbrnc/aoe_cachecleaner": "*", "aoepeople/magento_enterprise": "1.13.1.0", "aoepeople/envsettingstool": "*" }, "config": { "bin-dir": "bin" } }

AOEpeople/composer-installers replaces

Hackathon Installer

some modules

Vanilla Magento Source

Tools,…

Page 40: Rock-solid Magento Deployments (and Development)

Directory layout

Webroot:

/var/www/<projectName>/<environmentName>/current/htdocs

var

var

<projectName>

releases

<environmentName>

shared

www

media

build_117

build_118

build_119

.modman

htdocs

Configuration

tools

install.sh

app,…

var

media

previous

latest

current

next

My_Module

My_Module2

Page 41: Rock-solid Magento Deployments (and Development)

Magento Modules 3rd Party

Page 42: Rock-solid Magento Deployments (and Development)

discover use

code

review

add

modman

add

composer git integrate test

deploy

Magento Connect

The Right Thing™

one-click

install

download

good luck with that!

Page 43: Rock-solid Magento Deployments (and Development)

Code Quality Modules

Not enterprise

ready

Not production

ready

Not cloud

ready

Bad

performance

Security

Page 44: Rock-solid Magento Deployments (and Development)

0%

100%

Writing

Code

Time spent…

5 years ago today

Drinking Coffee Drinking Coffee

while waiting for builds/tests

Twitter

VCS

Deployment

Design / Architecture /

Infrastructure

Writing Code

Ping Pong

Think about it

Page 45: Rock-solid Magento Deployments (and Development)

master

Feature B

Feature A

Hotfix (if master is not modified)

Hotfix (if master is modified)

Feature C

build

install on

integration

tests

build

install on

integration

tests

install on

deploy

build

install on

integration

tests

deploy to

stage

deploy to

prod

Git Workflow

build

install on

integration

tests

deploy to

stage

deploy to

prod

build

install on

integration

tests

deploy to

stage

deploy to

prod

single mainline

no commits, only --no-ff

merges

Page 46: Rock-solid Magento Deployments (and Development)

build

Page 47: Rock-solid Magento Deployments (and Development)

to recreate What do we need

an environment?

Page 48: Rock-solid Magento Deployments (and Development)

Build Packaging

Page 49: Rock-solid Magento Deployments (and Development)

System Storage

Database dump

media directory (sometimes minified)

Page 50: Rock-solid Magento Deployments (and Development)

Staging Integration Devbox Production Deploy

“Master System”

Page 51: Rock-solid Magento Deployments (and Development)

Settings Urls

Database Settings

Payment Provider

Configuration

Feature Flags…

Everything that’s different between two environments

Page 52: Rock-solid Magento Deployments (and Development)

EnvSettingsTool

Page 53: Rock-solid Magento Deployments (and Development)
Page 54: Rock-solid Magento Deployments (and Development)

Settings Injection

Page 55: Rock-solid Magento Deployments (and Development)

not go on What should

production? Every file is a

potential security risk

Don’t deploy anything you don’t need to operate the

website

Page 56: Rock-solid Magento Deployments (and Development)

.git*

./htdocs/includes

./htdocs/downloader

./htdocs/pkginfo

./htdocs/LICENSE*

./htdocs/RELEASE_NOTES.txt

./htdocs/phpunit.xml*

./htdocs/*.sample

./htdocs/var

./htdocs/media

./.modman/Aoe_TemplateHints

./.modman/Aoe_Profiler

./.modman/EcomDev_PHPUnit

Page 57: Rock-solid Magento Deployments (and Development)

Extra Base vs.

production, staging,…

devbox and integration environment

Page 58: Rock-solid Magento Deployments (and Development)

Continuous Integration

Deployment

Development

Delivery

Improvement

Page 59: Rock-solid Magento Deployments (and Development)

Jenkins Travis CI Use Jenkins to implement a full deployment pipeline for

your projects!

Test our Open Source Magento modules with Travis CI!

Page 60: Rock-solid Magento Deployments (and Development)

https://github.com/AOEpeople/MageTestStand

MageTestStand

Page 61: Rock-solid Magento Deployments (and Development)

Vagrant Boxes

Page 62: Rock-solid Magento Deployments (and Development)

Awesome stuff

Every single line potentially

can break production!

Bratwurst (Germans)

Donut (Americans)

Pizza (Italians)

Page 63: Rock-solid Magento Deployments (and Development)

Version Control

GIT, SVN,…

PHP lint

Page 64: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews

Gerrit, Crucible, reVu,…

Page 65: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Triggered by commit, by time

or manually

Jenkins

minify js/css

.tar.gz

“virtual package” (revision)

Page 66: Rock-solid Magento Deployments (and Development)

Version

Control Code

Reviews Build

Files

DB

Instal

ler Setti

ngs

Page 67: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

CodeSniffer

php-pmd

php-cpd

php-depend

Page 68: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration”

First system where code from all

developers/teams meets each other

unstable system. Might be broken. Will be rebuild

without warning

Page 69: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests

PHPUnit

Code coverage

Page 70: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests Integration Tests

AOE PMD (for Magento)

broken links, HTTP headers, W3C validity,…

Test features that rely on other parts (e.g. framework, external

services,…) External components

(SSL, Redis, Varnish, ERP, Data Import,…)

Basically this is also PHPUnit, but

addressing other stuff

Page 71: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests Integration Tests Acceptance Tests

Selenium

Firefox Other Browsers

Page 72: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests Integration Tests Acceptance Tests

Install on

“Staging”

Behat (Cucumber)

Same setup as production, but different machines

Client QA / approval

Page 73: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests Integration Tests Acceptance Tests

Install on

“Staging”

*http://www.slideshare.net/aoemedia/performance-measurement-and-tuning

Stress

Tests

Jmeter

Spin up EC2 instances in the cloud to produce

traffic*

Page 74: Rock-solid Magento Deployments (and Development)

Again: multiple servers or autoscaling setup

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests Integration Tests Acceptance Tests

Install on

“Staging”

Stress

Tests

Install on

“Production”

A/B Deployments on different

scales

Plan B: rollback

Zero Downtime

Page 75: Rock-solid Magento Deployments (and Development)

Deployment != Feature Release

Page 76: Rock-solid Magento Deployments (and Development)

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code

Analysis

Install on

“Integration” Unit Tests Integration Tests Acceptance Tests

Install on

“Staging”

Stress

Tests

Install on

“Production” Enable Features

Page 77: Rock-solid Magento Deployments (and Development)

Version

Control Code

Reviews Build Static Code

Analysis

Install on

“Integration”

Unit Tests Integration

Tests

Acceptance

Tests

Install on

“Staging”

Install on

“Production” Enable

Features

Page 78: Rock-solid Magento Deployments (and Development)

Pipeline Visualization

#284

#283

#282

#281

#280

Build Static Code

Analysis Unit Tests

Install on “Integration”

Integration Tests

Acceptance Tests

#285

for team dashboards

Page 79: Rock-solid Magento Deployments (and Development)
Page 80: Rock-solid Magento Deployments (and Development)

deploy to

production

deploy to

production

Continuous Integration

Continuous Deployment

type “YESIKNOWWHATIMDOING” + click

Page 81: Rock-solid Magento Deployments (and Development)

deploy

Page 82: Rock-solid Magento Deployments (and Development)

Automate!

Page 83: Rock-solid Magento Deployments (and Development)

tim

e s

pe

nt

task size

does it manually

does it manually

gets annoyed

writes script to automate

runs script

wins

loses

Geeks vs. Non-Geeks

Makes fun of geek’s complicated method

Page 84: Rock-solid Magento Deployments (and Development)

Deploy often!

Page 85: Rock-solid Magento Deployments (and Development)

No manual interaction!

no creating CMS blocks

no creating product attributes

no updating of any configuration settings!

no clearing the cache

no purging CDN or Reverse Proxy

content!

Page 86: Rock-solid Magento Deployments (and Development)

Details? High Performance Magento in the Cloud

Page 87: Rock-solid Magento Deployments (and Development)

Deployment Strategy

Page 88: Rock-solid Magento Deployments (and Development)
Page 89: Rock-solid Magento Deployments (and Development)
Page 90: Rock-solid Magento Deployments (and Development)

Deployment Pattern

Page 91: Rock-solid Magento Deployments (and Development)

Build Installation Deployment Provisioning

Page 92: Rock-solid Magento Deployments (and Development)

Build What is it?

A simple shell script. That’s it! No Ant, no Phing, no fancy PHP tool/framework

Where is it used?

In the build job of a Jenkins server

What does it need to know?

Where to get all the source code from

What does it do?

add metadata, composer, modman, minify, packaging, upload to S3

Page 93: Rock-solid Magento Deployments (and Development)

Provisioning What is it?

A couple of chef cookbooks. Run by AWS OpsWorks or Vagrant,…

Where is it used?

On the target servers

What does it need to know?

The role of the server (web server, devbox, Redis,…)

What does it do?

Installing and configuring web server, PHP, MySQL, Redis,…

Page 94: Rock-solid Magento Deployments (and Development)

Deployment What is it?

A simple shell script. Or the “deploy” chef cookbook Or EasyDeployWorkflows

Where is it used?

On the target servers

What does it need to know?

How to get the build and where to deploy it to

What does it do?

(Resetting the environment), getting the build, extracting it, managing release folders and symlinks, triggering installer, cleanup old releases

Page 95: Rock-solid Magento Deployments (and Development)

Installation What is it?

A simple shell script. Sometimes triggered inside “deploy” before_migrate.rb

Where is it used?

On the target servers, called from deployment step

What does it need to know?

What environment this is. Injected settings

What does it do?

Run modman, connect to shared directories, apply settings, trigger update scripts, customize cache prefix,

Page 96: Rock-solid Magento Deployments (and Development)

Deployment != Installation

doesn’t know anything about the app, except where to get it from

and where to put it

knows how to get the app up and running

Page 97: Rock-solid Magento Deployments (and Development)

Cache Invalidation

Cache Warming

add build number to id_prefix

Page 98: Rock-solid Magento Deployments (and Development)

Devbox

VirtualBox Vagrant Chef

Page 99: Rock-solid Magento Deployments (and Development)

Unibox

https://github.com/AOEpeople/chef-devbox

Page 100: Rock-solid Magento Deployments (and Development)

Build Installation Deployment Provisioning

Chef

deploy.sh install.sh

Jenkins

Page 101: Rock-solid Magento Deployments (and Development)

Sa

mb

a

VM Host

Apache

Windows Ubuntu

SS

H

Page 102: Rock-solid Magento Deployments (and Development)

test

Page 103: Rock-solid Magento Deployments (and Development)

Unit

Service

UI Acceptance

http://www.mountaingoatsoftware.com/blog/the-forgotten-layer-of-the-test-automation-pyramid

What the customer thinks

the code should do

What the developer thinks

the code should do

Load Test

Page 104: Rock-solid Magento Deployments (and Development)

Menta Selenium 2 Testing Framework for PHP

Who is “Menta”?

What is “Menta”?

Page 105: Rock-solid Magento Deployments (and Development)

Gallery Screenshot

Page 106: Rock-solid Magento Deployments (and Development)

Perceptual diffs Build X

Build X-1

Perceptual Diff

Page 107: Rock-solid Magento Deployments (and Development)

https://plus.google.com/116116065378190790516

Magento Fireside Chats

Page 108: Rock-solid Magento Deployments (and Development)

plan

code build

test

deploy operate

Page 109: Rock-solid Magento Deployments (and Development)

Continuous Improvement

Page 110: Rock-solid Magento Deployments (and Development)

give take and

be part of the community

Page 111: Rock-solid Magento Deployments (and Development)

#SinceIStartedWithMagento

Page 112: Rock-solid Magento Deployments (and Development)

http://joind.in/talk/view/11899

Page 113: Rock-solid Magento Deployments (and Development)

Thank you! Any questions?

{firstname}.{lastname}@aoe.com

http://www.aoe.com

http://www.fabrizio-branca.de

@fbrnc Follow me on twitter!

My blog


Recommended