+ All Categories
Home > Technology > Rock-solid Magento Development and Deployment Workflows

Rock-solid Magento Development and Deployment Workflows

Date post: 08-Jan-2017
Category:
Upload: aoe
View: 6,523 times
Download: 2 times
Share this document with a friend
79
Transcript
Page 1: Rock-solid Magento Development and Deployment Workflows
Page 2: Rock-solid Magento Development and Deployment Workflows

2 October 26, 2015

Page 3: Rock-solid Magento Development and Deployment Workflows
Page 4: Rock-solid Magento Development and Deployment Workflows

San Francisco, CA

Janine

Fiona

that’s me

Leo

Page 5: Rock-solid Magento Development and Deployment Workflows

Continuous Development

Continuous Delivery

Continuous Integration

Continuous Deployment

Continuous Monitoring

Continuous

Jenkins

Everything sounds better with “continuous”

Page 6: Rock-solid Magento Development and Deployment Workflows

plan

code build

test

deploy operate

Page 7: Rock-solid Magento Development and Deployment Workflows

http://kirbiecravings.com/2014/08/blueberry-mug-cake-2.html

Page 8: Rock-solid Magento Development and Deployment Workflows

code

Page 9: Rock-solid Magento Development and Deployment Workflows
Page 10: Rock-solid Magento Development and Deployment Workflows

CMS

Magento

Solr

ERP

Project

Applications

Magento Magento

117

Magento

118

Magento

119

Builds

Release

Page 11: Rock-solid Magento Development and Deployment Workflows

Staging

Magento

72

Magento

103

Magento

119

Magento

72

Magento

103

Magento

119

Magento

72

Magento

103

Magento

119

Environment

Servers

Instances

Page 12: Rock-solid Magento Development and Deployment Workflows

Staging Integration Devbox Production Deploy

transient, potentially broken

Page 13: Rock-solid Magento Development and Deployment Workflows

Staging Integration Devbox Production Deploy

VirtualBox + Vagrant

Jenkins Server

identical setup

Page 14: Rock-solid Magento Development and Deployment Workflows

One size doesn’t fit all!

Page 15: Rock-solid Magento Development and Deployment Workflows
Page 16: Rock-solid Magento Development and Deployment Workflows

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, minify, packaging, upload to S3

Page 17: Rock-solid Magento Development and Deployment Workflows

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 18: Rock-solid Magento Development and Deployment Workflows

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 19: Rock-solid Magento Development and Deployment Workflows

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, apply settings, trigger update scripts, customize cache prefix, indexing,…

Page 20: Rock-solid Magento Development and Deployment Workflows

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 21: Rock-solid Magento Development and Deployment Workflows
Page 22: Rock-solid Magento Development and Deployment Workflows

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 23: Rock-solid Magento Development and Deployment Workflows

media directory (sometimes minified)

Database dump

(Vanilla) Magento core

Modules

Scripts

Settings

Tools

Page 24: Rock-solid Magento Development and Deployment Workflows

Structure Project

Page 25: Rock-solid Magento Development and Deployment Workflows

project web root root

This is the complete project

This is where your webserver points to.

Page 26: Rock-solid Magento Development and Deployment Workflows

project web root root

Page 27: Rock-solid Magento Development and Deployment Workflows

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

Page 28: Rock-solid Magento Development and Deployment Workflows

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 29: Rock-solid Magento Development and Deployment Workflows

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 30: Rock-solid Magento Development and Deployment Workflows

by @colinmollenhour

Page 31: Rock-solid Magento Development and Deployment Workflows

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 32: Rock-solid Magento Development and Deployment Workflows

Vanilla Magento

absolutely no core hacks!

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

Magento, of course…)

(except official patches)

Page 33: Rock-solid Magento Development and Deployment Workflows

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

Page 34: Rock-solid Magento Development and Deployment Workflows

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

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 35: Rock-solid Magento Development and Deployment Workflows
Page 36: Rock-solid Magento Development and Deployment Workflows

“inspired” by composer/installers

handles package types

Page 37: Rock-solid Magento Development and Deployment Workflows

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

Page 38: Rock-solid Magento Development and Deployment Workflows

• 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

Page 39: Rock-solid Magento Development and Deployment Workflows

{ "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" } }

replaces Hackathon Installer

some modules

Vanilla Magento Source

Tools,…

Page 40: Rock-solid Magento Development and Deployment Workflows

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 Development and Deployment Workflows

https://github.com/AOEpeople/Magento_Boilerplate

Page 42: Rock-solid Magento Development and Deployment Workflows
Page 43: Rock-solid Magento Development and Deployment Workflows

discover use

code

review

add

modman

add

composer git integrate test

deploy

download

good luck with that!

pay $xx

to author provide FTP

access

seriously?!

one-click

install

upload

“Step 1”

upload

“Step 2”

clear

caches

Page 44: Rock-solid Magento Development and Deployment Workflows

Code Quality Modules

Not enterprise ready

Not production ready

Not cloud ready Bad performance

Security

Page 45: Rock-solid Magento Development and Deployment Workflows

Urls

Database Settings

Payment Provider Configuration Feature

Flags…

Everything that’s different between two

environments

Page 46: Rock-solid Magento Development and Deployment Workflows

Zettr

Page 47: Rock-solid Magento Development and Deployment Workflows
Page 48: Rock-solid Magento Development and Deployment Workflows
Page 49: Rock-solid Magento Development and Deployment Workflows

Every file is a potential security risk

Don’t deploy anything you don’t need to

operate the website

Page 50: Rock-solid Magento Development and Deployment Workflows

.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 51: Rock-solid Magento Development and Deployment Workflows

production, staging,…

devbox and integration environment

Page 52: Rock-solid Magento Development and Deployment Workflows

Vagrant Boxes

Page 53: Rock-solid Magento Development and Deployment Workflows

Awesome stuff

Every single line potentially

can break production!

Bratwurst (Germans)

Donut (Americans)

Pizza (Italians)

Page 54: Rock-solid Magento Development and Deployment Workflows

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

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 55: Rock-solid Magento Development and Deployment Workflows

Version Control

GIT, SVN,…

PHP lint

Page 56: Rock-solid Magento Development and Deployment Workflows

Version Control Code Reviews

Crucible,…

Page 57: Rock-solid Magento Development and Deployment Workflows

Version Control

Code Reviews

Build

Files

DB

Installer

Settings

Page 58: Rock-solid Magento Development and Deployment Workflows

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code Analysis

CodeSniffer

php-pmd

php-cpd

php-depend

Page 59: Rock-solid Magento Development and Deployment Workflows

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 rebuilt without warning

Page 60: Rock-solid Magento Development and Deployment Workflows

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code Analysis

Install on “Integration”

Unit Tests

PHPUnit

Page 61: Rock-solid Magento Development and Deployment Workflows

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 things

Page 62: Rock-solid Magento Development and Deployment Workflows

Version Control Code Reviews Build

Files

DB

Installer

Settings

Static Code Analysis

Install on “Integration”

Unit Tests Integration Tests Acceptance Tests

Selenium

Page 63: Rock-solid Magento Development and Deployment Workflows

Firefox

Chrome

browser

size

640

980

1280

1900

US languages

UK DE FR IT

Page 64: Rock-solid Magento Development and Deployment Workflows

language

size

browser

touchstone job

Page 65: Rock-solid Magento Development and Deployment Workflows

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, PDIFF,…

Same setup as production, but different machines

Client QA / approval

Page 66: Rock-solid Magento Development and Deployment Workflows

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

JMeter

Spin up EC2 instances to

produce traffic

Page 67: Rock-solid Magento Development and Deployment Workflows

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 68: Rock-solid Magento Development and Deployment Workflows
Page 69: Rock-solid Magento Development and Deployment Workflows
Page 70: Rock-solid Magento Development and Deployment Workflows
Page 71: Rock-solid Magento Development and Deployment Workflows

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”

Page 72: Rock-solid Magento Development and Deployment Workflows

Deployment != Feature Release

Page 73: Rock-solid Magento Development and Deployment Workflows

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 74: Rock-solid Magento Development and Deployment Workflows

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 75: Rock-solid Magento Development and Deployment Workflows

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 76: Rock-solid Magento Development and Deployment Workflows
Page 77: Rock-solid Magento Development and Deployment Workflows

type “YESIKNOWWHATIMDOING” + click

automatically

Page 78: Rock-solid Magento Development and Deployment Workflows

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

Page 79: Rock-solid Magento Development and Deployment Workflows

Follow me on twitter!

My blog


Recommended