symfonycon madrid 2014 - rock solid deployment of symfony apps

174
Photo: Alvaro Videla Pablo Godel @pgodel Rock Solid Deployment of Symfony Applications Photo by @old_sound https://joind.in/12960

Upload: pablo-godel

Post on 04-Jul-2015

3.281 views

Category:

Technology


2 download

DESCRIPTION

Web applications are becoming increasingly more complex, so deployment is not just transferring files with FTP anymore. We will go over the different challenges and how to deploy our PHP applications effectively, safely and consistently with the latest tools and techniques. We will also look at tools that complement deployment with management, configuration and monitoring.

TRANSCRIPT

Page 1: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Photo: Alvaro Videla

Pablo Godel @pgodel

Rock Solid Deployment of Symfony

Applications

Photo by @old_sound

https://joind.in/12960

Page 2: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Hi, I am Pablo.

Page 3: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Hi, I am Pablo. !

@pgodel

Page 4: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 5: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 6: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

A GUIDING LIGHT FOR STUDENT SUCCESS

Page 7: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Symfony2 + AngularJS + much more!

A GUIDING LIGHT FOR STUDENT SUCCESS

Page 8: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

We are Hiring!

A GUIDING LIGHT FOR STUDENT SUCCESS

Page 9: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

?

Page 10: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

Software deployment is all of the activities that !make a software system available for use.

http://en.wikipedia.org/wiki/Software_deployment

Page 11: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

A very important part of the application life-cycle

Page 12: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

A very important critical part of the application life-cycle

Page 13: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

It should not be an !after thought

Page 14: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

It should be predictable

Page 15: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment

The more you do it the better it goes

Page 16: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 17: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 18: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 19: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 20: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment in the PaaS era

Page 21: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

1. Open an account

Page 22: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

2. Create app

Page 23: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

3. Push code

Page 24: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

4. Voilà!

Page 25: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 26: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

composer.json !!

Procfile

Page 27: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

$ heroku create!

Page 28: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

$ git push heroku master!

Page 29: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps
Page 30: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

$ heroku ps:scale web=5!

Page 31: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

That’s it! ;-)

Page 32: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Questions?

Slides: http://slideshare.net/pgodel Twitter: @pgodel

Page 33: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

But…

Page 34: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment for the rest of us

Page 35: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Goals

Page 36: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

One-click deploys

Deployment Goals

Page 37: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

One-click deploys

Deployment Goals

Page 38: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Continuous deploys

Deployment Goals

Page 39: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Continuous deploys

Deployment Goals

Page 40: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Anytime & Anywhere

Deployment Goals

Page 41: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Anytime & Anywhere

Deployment Goals

Page 42: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Anyone

Deployment Goals

Page 43: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Anyone

Deployment Goals

Page 44: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Reliable

Deployment Goals

Page 45: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Reliable

Deployment Goals

Page 46: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Rollbacks

Deployment Goals

Page 47: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Rollbacks

Deployment Goals

Page 48: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

No downtime

Deployment Goals

Page 49: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

No downtime

Deployment Goals

Page 50: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Reusable

Deployment Goals

Page 51: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Reusable

Deployment Goals

Page 52: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Reusable

Deployment Goals

Page 53: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Scalable

Deployment Goals

Page 54: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Scalable

Deployment Goals

Page 55: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Facts

Page 56: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment starts with the developer

Deployment Fact #1

Page 57: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment starts with the developer

• Development environment must be as close as possible to productions servers!

Deployment Fact #1

Page 58: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment starts with the developer

• Development environment must be as close as possible to productions servers!

• Setup test/qa/staging servers!

Deployment Fact #1

Page 59: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment starts with the developer

• Development environment must be as close as possible to productions servers!

• Setup test/qa/staging servers!• Use Vagrant to manage VMs!

Deployment Fact #1

Page 60: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment starts with the developer

• Development environment must be as close as possible to productions servers!

• Setup test/qa/staging servers!• Use Vagrant to manage VMs!• Use Containers with Docker!

Deployment Fact #1

Page 61: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment starts with the developer

• Development environment must be as close as possible to productions servers!

• Setup test/qa/staging servers!• Use Vagrant to manage VMs!• Use Containers with Docker!• Automate your development environment setup

(Ansible, Homebrew Cask)

Deployment Fact #1

Page 62: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Success depends on server OS setup

Deployment Fact #2

Page 63: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Success depends on server OS setup

• Automate installation/configuration with Ansible/Puppet/Chef !

Deployment Fact #2

Page 64: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Automate installation/configuration with Ansible/Puppet/Chef !

• Create OS packages for 3rd party software

Deployment Fact #2

Success depends on server OS setup

Page 65: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Automate installation/configuration with Ansible/Puppet/Chef !

• Create OS packages for 3rd party software!• Setup your own package (rpm/deb) repositories

Deployment Fact #2

Success depends on server OS setup

Page 66: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Monitoring is uptime

Deployment Fact #3

Page 67: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Monitoring is uptime

• Use tools to know what is going on with your servers (Ganglia, Cacti, Zabbix, etc.)!

Deployment Fact #3

Page 68: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Monitoring is uptime

• Use tools to know what is going on with your servers (Ganglia, Cacti, Zabbix, etc.)!

Deployment Fact #3

Page 69: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Monitoring is uptime

• Use tools to know what is going on with your servers (Ganglia, Cacti, Zabbix, etc.)!

• Add metrics to your app (Graphite, StatsD, New Relic)!

Deployment Fact #3

Page 70: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Monitoring is uptime

• Use tools to know what is going on with your servers (Ganglia, Cacti, Zabbix, etc.)!

• Add metrics to your app (Graphite, StatsD, New Relic)!

• Use your logs wisely (Logstash, Hecka, Kibana)

Deployment Fact #3

Page 71: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

Page 72: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style

Page 73: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads

Page 74: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads

Page 75: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads!• Rsync

Page 76: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads!• Rsync!• Source control (GIT, SVN)

Page 77: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads!• Rsync!• Source control (GIT, SVN)!• Build tools (Ant, Phing, Jenkins)!

Page 78: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads!• Rsync!• Source control (GIT, SVN)!• Build tools (Ant, Phing, Jenkins)!• Package based (RPM, DEB, …) !

Page 79: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads!• Rsync!• Source control (GIT, SVN)!• Build tools (Ant, Phing, Jenkins)!• Package based (RPM, DEB, …) !• Specialized tools (Capifony, Deployer, …)!

Page 80: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Methodologies

• VIM-style!• FTP uploads!• Rsync!• Source control (GIT, SVN)!• Build tools (Ant, Phing, Jenkins)!• Package based (RPM, DEB, …) !• Specialized tools (Capifony, Deployer, …)!• IT automation tools (Ansible, Puppet, Chef, …)

Page 81: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment: Steps overview

Page 82: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment: First time

• Copy files to server(s)!• Set server-side configurations!• Load DB fixtures!• Process and install assets!• Warm up cache!• Enable site

Page 83: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment: Subsequent times

• Copy files to server(s)!• Update server-side configurations!• Update DB (migrations)!• Process and install assets!• Warm up cache!• Enable new version

Page 84: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

We can automate!

Page 85: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Challenges

Page 86: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Secure

Deployment Challenges

Page 87: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• use ssh based connections!

Challenge: Secure

Deployment Challenges

Page 88: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• use ssh based connections!• don’t store passwords on source control

Challenge: Secure

Deployment Challenges

Page 89: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• use ssh based connections!• don’t store passwords on source control!• use environment variables for sensitive data

Challenge: Secure

Deployment Challenges

Page 90: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Static assets

Deployment Challenges

Page 91: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Static assets

• Minimize/combine JS and CSS files!

Deployment Challenges

Page 92: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Static assets

• Minimize/combine JS and CSS files!• Enable web server compression!

Deployment Challenges

Page 93: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Static assets

• Minimize/combine JS and CSS files!• Enable web server compression!• Add versioning to static assets links (code.js?v=1)!

Deployment Challenges

Page 94: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Static assets

• Minimize/combine JS and CSS files!• Enable web server compression!• Add versioning to static assets links (code.js?v=1)!• Run utilities locally or in a staging server, create

artifact, deploy result!

Deployment Challenges

Page 95: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: Static assets

• Minimize/combine JS and CSS files!• Enable web server compression!• Add versioning to static assets links (code.js?v=1)!• Run utilities locally or in a staging server, create

artifact, deploy result!• Serve static files from subdomain / CDN

Deployment Challenges

Page 96: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: File permission conflicts

Deployment Challenges

Page 97: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: File permission conflicts

• Run Apache/PHP with same user!

Deployment Challenges

Page 98: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: File permission conflicts

• Run Apache/PHP with same user!• Use php-fpm instead of mod_php!

Deployment Challenges

Page 99: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: File permission conflicts

• Run Apache/PHP with same user!• Use php-fpm instead of mod_php!• Create “deploy” user and add web server to the

group

Deployment Challenges

Page 100: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: File permission conflicts

• Run Apache/PHP with same user!• Use php-fpm instead of mod_php!• Create “deploy” user and add web server to the

group!• Use setfacl to give write access to multiple users!

Deployment Challenges

Page 101: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Challenge: File permission conflicts

• Run Apache/PHP with same user!• Use php-fpm instead of mod_php!• Create “deploy” user and add web server to the

group!• Use setfacl to give write access to multiple users!• Use external services for writing files and create

readonly installations

Deployment Challenges

Page 102: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Common Pitfalls

Page 103: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!

Common Pitfalls

Page 104: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!!

src/Acme/ClassName !!= !src/Acme/Classname.php

Common Pitfalls

Page 105: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!!

src/Acme/ClassName !!= !src/Acme/Classname.php

Common Pitfalls

Page 106: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!• Configuration differences!

Common Pitfalls

Page 107: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!• Configuration differences!• Outdated 3rd party software

Common Pitfalls

Page 108: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!• Configuration differences!• Outdated 3rd party software!• Github down

Common Pitfalls

Page 109: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!• Configuration differences!• Outdated 3rd party software!• Github down

$ git daemon --base-path=/git/repo/path/ --export-all!!

$ git clone git://127.0.0.1/repo!

http://ozmm.org/posts/when_github_goes_down.html

Common Pitfalls

Page 110: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Case sensitive filesystems!• Configuration differences!• Outdated 3rd party software!• Github down

Common Pitfalls

Page 111: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples

Page 112: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Simplest continuous deployment ever!

<?php !!exec(‘/usr/bin/env -i HOME=/var/www git pull’);!echo “All done!”;

hook.php

Deployment Examples

Page 113: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

<?php !!exec(‘/usr/bin/env -i HOME=/var/www git pull’);!echo “All done!”;

hook.php

screenshot

Deployment Examples

GitHub hook

Simplest continuous deployment ever!

Page 114: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Capistrano!!

+ !!

Capifony

Deployment Examples

Page 115: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Capistrano / Capifony

• Ruby based!• Very extensible!• Large number of extensions!• Simple client side installation

Deployment Examples

Page 116: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

• Ruby based!• Very extensible!• Large number of extensions!• Simple client side installation

$ gem install capifony!

Deployment Examples

Capistrano / Capifony

Page 117: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

set :application, "myapp" # Application name set :deploy_to, "/var/www/myapp" !set :user, "deployer" set :use_sudo, false # sudo isn't required !set :deploy_via, :remote_cache set :repository, "[email protected]:user/repo.git" !role :web, "server.example.com", “server2.example.com”

Deployment Examples

Capistrano / Capifony

Page 118: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

$ cap deploy:setup

Deployment Examples

Capistrano / Capifony

Page 119: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

!

|-- releases!`-- shared! |-- logs! `-- uploads!

Deployment Examples

Capistrano / Capifony

Page 120: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

$ cap deploy!$ cap deploy:migrations!$ cap deploy:rollback!

Deployment Examples

Capistrano / Capifony

Page 121: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

!

|-- current (symlink to releases/20130112)!|-- releases!| `-- 20130112!`-- shared! |-- logs! `-- uploads!

Deployment Examples

Capistrano / Capifony

Page 122: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples

Deploying with

Page 123: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples!

!

Define hosts in inventory file[webservers] foo.example.com bar.example.comwww[01:50].example.com ![dbservers] one.example.com two.example.com three.example.com

Page 124: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples!

!

Define tasks / actions in playbook--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running service: name=httpd state=started

Page 125: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples!

!

Reuse tasks with Roles- hosts: webservers roles: - { role: servergrove.symfony2, symfony2_project_root: /var/www/vhosts/example.com/, symfony2_project_name: demo, symfony2_project_branch: master , symfony2_project_release: 1 }

Page 126: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples!

!

Run process

$ ansible-playbook -i inventories/servers \ playbook.yml -v

Page 127: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Examples!

!

Run process

Page 128: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment: Other options

• Fabric (Python) • Idephix (PHP) • Magellanes (PHP) • Deployer (PHP) • Laravel / envoy (PHP) • Rocketeer (PHP)

Page 129: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Complement Tools

Page 130: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Packaging: fpm

https://github.com/jordansissel/fpm

Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.

$ fpm -s dir -t rpm -n "myapp" -v 1.0 /var/www/myapp !$ fpm -s dir -t deb -a all -n myapp -v 1.0 /etc/apache2/conf.d/my.conf /var/www/myapp

Deployment Complement Tools

Page 131: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: StatsD & Graphite

Deployment Complement Tools

Page 132: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: liuggio/statsd-php-client

Deployment Complement Tools

$ composer require liuggio/statsd-php-client

Page 133: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: liuggio/statsd-php-client

Deployment Complement Tools

$sender = new SocketSender(/*'localhost', 8126, 'udp'*/); !$client = new StatsdClient($sender); $factory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData'); !// create the data with the factory $data[] = $factory->timing('usageTime', 100); $data[] = $factory->increment('visitor'); $data[] = $factory->decrement('click'); $data[] = $factory->gauge('gaugor', 333); $data[] = $factory->set('uniques', 765); !// send the data as array or directly as object $client->send($data);

Page 134: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: liuggio/statsd-php-client

Deployment Complement Tools

$data[] = $factory->timing('usageTime', 100);!!

// send the data as array or directly as object $client->send($data);

Page 135: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: liuggio/statsd-php-client

Deployment Complement Tools

$data[] = $factory->increment('orders');!!

// send the data as array or directly as object $client->send($data);

Page 136: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: liuggio/statsd-php-client

Deployment Complement Tools

$data[] = $factory->gauge('memory', 333);!!

// send the data as array or directly as object $client->send($data);

Page 137: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

App Metrics: StatsD & Graphite

Deployment Complement Tools

App

StatsD Graphite

Grafana

App App

Page 138: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Complement Tools

App Metrics: Grafana

Page 139: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Complement Tools

App Metrics: Grafana

Page 140: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Logging: LogstashShip logs from any source, parse them, get the right timestamp, index them, and search them

Deployment Complement Tools

input { file { path => “/var/log/apache2/access_log” } } output { elasticsearch { host => localhost } }

Page 141: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Configure Apache to log jsonLogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"referrer\": \"%{Referer}i\" } }" logstash_json!!!# Write our 'logstash_json' logs to logs/access_json.log!CustomLog logs/access_json.log logstash_json!

Deployment Complement Tools

Logging: Logstash

Page 142: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Configure Apache to log jsonLogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"referrer\": \"%{Referer}i\" } }" logstash_json!!!# Write our 'logstash_json' logs to logs/access_json.log!CustomLog logs/access_json.log logstash_json!

{ "@timestamp": "2012-08-22T14:35:19-0700", "client": "127.0.0.1", "duration_usec": 532, "status": 404, "request": "/favicon.ico", "method": "GET", "referrer": "-" }!

Result

Deployment Complement Tools

Logging: Logstash

Page 143: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Logging: KibanaKibana is a user friendly way to view, search and visualize your log data

Deployment Complement Tools

Page 144: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Logging: KibanaKibana is a user friendly way to view, search and visualize your log data

Deployment Complement Tools

Page 145: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Logging: Logstash + ElasticSearch + Kibana

Deployment Complement Tools

App / Logstash

Redis Logstash filter/processor

ElasticSearch Kibana

App / Logstash App / Logstash

Page 146: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Summary

Page 147: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 148: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 149: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 150: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 151: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 152: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 153: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 154: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 155: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 156: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 157: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Developer Tests

build artifact

Ansible Production

GitHub

Jenkins QA deploy

Integration Tests

Notifications

Deployment Summary

Page 158: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Future

Page 159: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Future

Containers

Page 160: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Future

Docker

Web App

Linux

Apache / PHP

Page 161: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Deployment Future

DockerHost

Docker client

CVM

Web Server

DB Server

App Server

C C

Page 162: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

Deployment Future

Page 163: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

Deployment Future

Page 164: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

Host

C

VM

Web Server

DB Server

App Server

C C

Deployment Future

Page 165: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

Host

C

VM

Web Server

DB Server

App Server

C C

Host

C

Web Server

DB Server

App Server

C C

Docker Kernel

Deployment Future

Page 166: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Final Thoughts

Page 167: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Stop using FTP

Page 168: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Plan early

Page 169: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Practice

Page 170: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Monitor

Page 171: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

AUTOMATE!

Page 172: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Now, we did finish! !

Questions?

Page 173: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Feedback Please! !

!

http://slideshare.net/pgodel @pgodel

https://joind.in/12960

Page 174: SymfonyCon Madrid 2014 - Rock Solid Deployment of Symfony Apps

Feedback Please! !

!

Thank you!

http://slideshare.net/pgodel @pgodel

https://joind.in/12960