Developing locally with virtual machines

32
DEVELOPING LOCALLY WITH VIRTUAL MACHINES William Hurley, Manager of Programming April 11, 2014 Monday, April 14, 14

description

How to develop Drupal locally with virtual machines and why you would want to.

Transcript of Developing locally with virtual machines

Page 1: Developing locally with virtual machines

DEVELOPING LOCALLY WITH VIRTUAL MACHINES

William Hurley, Manager of ProgrammingApril 11, 2014

Monday, April 14, 14

Page 2: Developing locally with virtual machines

About Forum One

1,500  projects  since  1996Full  Service  Strategy  +  UX  +  Tech  +  Support

100%  Open  Source!

Monday, April 14, 14

Page 3: Developing locally with virtual machines

75  Staff  Members  inAlexandria,  SeaJle,

San  Francisco  and  more!

Monday, April 14, 14

Page 4: Developing locally with virtual machines

The Challenge

Monday, April 14, 14

Page 5: Developing locally with virtual machines

In 2008

LAMPinux

pache

ySql

HP

Monday, April 14, 14

Page 6: Developing locally with virtual machines

In 20084  languages

PHP

SQL

CSS  /  JS

3  services

Apache

MySQL

PHP  with  mod_php

5  Developers

1  Themer

2  System  Administrators

Everyone  in  one  building

Monday, April 14, 14

Page 7: Developing locally with virtual machines

In 2014

LNMPSVMinux

nginx

ySql

HP

olr

arnish

emcached

Monday, April 14, 14

Page 8: Developing locally with virtual machines

In 201415  Developers

5  Interface  Engineers

2  Technical  PM

10  Contractors

2  System  Administrators

Working  across  the  US  and  Europe

7  languages

PHP

SQL

Ruby

Java

SASS  /  CSS  /  JS

7  services

Apache

nginx

MySQL

PostgreSQL

Solr

Varnish

Memcached

Redis

NodeJSMonday, April 14, 14

Page 9: Developing locally with virtual machines

Develop and SupportLaunched  29  sites  in  2013

AcUvely  host  and  support  65+  sites

Drupal  6  and  7,  even  some  Drupal  5

WordPress

Custom  applicaUons  in  Python,  NodeJS,  Zend  Framework,  Code  Igniter  and  others

Hosted  by  Forum  One,  Acquia,  Pantheon  and  others

Monday, April 14, 14

Page 10: Developing locally with virtual machines

Software and Versions MatterApache  or  nginx?

FPM  or  mod_php?

PHP  5.2,  5.3  or  5.4?

Ruby  1.8.7,  1.9  or  2.0?

Solr  3.5,  3.6,  4.4  or  4.6?

Redis  or  memcached

VarnishMonday, April 14, 14

Page 11: Developing locally with virtual machines

Looking to the FutureWeb  properUes  ge`ng  more  complex

New  technologies  -­‐-­‐  not  yet  easily  installed  on  consumer  systems

HHVM

PageSpeed

Mahout  /  Hadoop

Larger  and  more  distributed  teams

Monday, April 14, 14

Page 12: Developing locally with virtual machines

Solutions

Monday, April 14, 14

Page 13: Developing locally with virtual machines

Monday, April 14, 14

Page 14: Developing locally with virtual machines

What is it?“Vagrant  is  a  tool  for  building  complete  

development  environments.  With  an  easy-­‐to-­‐use  workflow  and  focus  on  automaUon,  Vagrant  lowers  development  environment  

setup  Ume,  increases  development/producUon  parity,  and  makes  the  "works  on  my  machine"  excuse  a  relic  of  the  past.”

Monday, April 14, 14

Page 15: Developing locally with virtual machines

What Does that Mean?Manages  per-­‐project  virtual  machines

Eases  configuraUon  for:

Port  forwarding

Shared  folders  including  NFS

SSH  agent  forwarding

Integrates  with  system  configuraUon  management

Monday, April 14, 14

Page 16: Developing locally with virtual machines

Why Does it Matter?Easily  create  new  projects  -­‐-­‐  just  run  “vagrant  up”

Keep  each  project  isolated

Keep  everyone  working  in  the  same  environment

Monday, April 14, 14

Page 17: Developing locally with virtual machines

Vagrant WorkflowCheck  out  repository

Run  “vagrant  up”

Log  in  to  VM  by  running  “vagrant  ssh”

Run  git  or  drush  from  the  VM  or  locally

Work  with  files  locally

Monday, April 14, 14

Page 18: Developing locally with virtual machines

Easy First StepsCreate  a  single  virtual  machine  with  sojware  you  need

Generate  template

Share  with  team

Monday, April 14, 14

Page 19: Developing locally with virtual machines

ChallengesMore  system  resources  necessary

Requires  use  of  the  command-­‐line

Does  not  preserve  idiosyncraUc  preferences

Requires  addiUonal  sojware  -­‐-­‐  some  changing  frequently

Not  all  drush  commands  work  well  from  outside  the  VM

Monday, April 14, 14

Page 20: Developing locally with virtual machines

Common IssuesOn  some  machines  Intel  VirtualizaUon  Technology  for  Directed  I/O  (VT-­‐d)  is  not  enabled

SSH  commands  need  the  host  SSH  key  in  the  SSH  agent  -­‐-­‐  ssh-­‐add

NaUve  file  sharing  on  OSX  and  Linux  is  slow  -­‐-­‐  use  NFS

Monday, April 14, 14

Page 21: Developing locally with virtual machines

Monday, April 14, 14

Page 22: Developing locally with virtual machines

What is it?“Puppet  is  IT  automaUon  sojware  that  helps  system  administrators  manage  infrastructure  throughout  its  lifecycle,  from  provisioning  and  configuraUon  to  orchestraUon  and  reporUng.  

Using  Puppet,  you  can  easily  automate  repeUUve  tasks,  quickly  deploy  criUcal  

applicaUons,  and  proacUvely  manage  change,  scaling  from  10s  of  servers  to  1000s,  on-­‐

premise  or  in  the  cloud.”

Monday, April 14, 14

Page 23: Developing locally with virtual machines

What Does that Mean?Ensures  current  environment  matches  configuraUon

Domain  specific  language  to  configure:

Services

Files

Permissions

Se`ngs

Monday, April 14, 14

Page 24: Developing locally with virtual machines

Alternatives

Monday, April 14, 14

Page 25: Developing locally with virtual machines

Why Does it Matter?Ability  to  customize  sojware  for  each  project  independently

Ability  to  customize  se`ngs  for  each  project  independently  and  share  those  se`ngs  with  each  team  member

Leverage  experUse  in  certain  technologies  across  the  enUre  team

Monday, April 14, 14

Page 26: Developing locally with virtual machines

ChallengesCentralizes  knowledge  and  experUse

Takes  Ume  to  provision  virtual  machine

Achieving  parity  with  developer  desired  tools  -­‐-­‐  e.g.  XDebug,  XHProf

Change  can  be  difficult

Monday, April 14, 14

Page 27: Developing locally with virtual machines

PuPHPetMonday, April 14, 14

Page 28: Developing locally with virtual machines

Other ExamplesDrupal-­‐VM  (github.com/Bussmeyer/drupal-­‐vm)

Varying  Vagrant  Vagrants  (github.com/Varying-­‐Vagrant-­‐Vagrants/VVV)

Kalabox  (www.kalamuna.com/products/kalabox)

Monday, April 14, 14

Page 29: Developing locally with virtual machines

Or Roll Your OwnAdvantages

Control  over  all  aspects  of  the  provisioning

Easy  to  use  organizaUon  specific  configuraUon  -­‐-­‐  e.g.  Varnish,  Solr,  nginx

Challenges

Takes  Ume  to  learn  tool

Limits  your  community

Monday, April 14, 14

Page 30: Developing locally with virtual machines

Key ComponentsLibrarian  Puppet

Puppet  modules  -­‐-­‐  Puppet  Forge,  Git

Hiera

Monday, April 14, 14

Page 31: Developing locally with virtual machines

Hiera---classes: - forumone::varnish - forumone::nodejs - forumone::ruby - memcached

forumone::webserver::webserver: nginx

forumone::php::modules: - pecl-memcached - xcache - gd php::modules: xcache: settings: xcache.size: "96M"

---classes: - forumone::webserver - forumone::php - forumone::drush - forumone::mailcatcher

forumone::php::modules: - xml - pdo - mbstring - mysql - pecl-xdebug

php::ini: display_errors: "On" memory_limit: "256M" upload_max_filesize: "50M" post_max_size: "100M" sendmail_path: "/usr/bin/env catchmail"

percona::conf: max_allowed_packets: content: "[mysqld]\nmax_allowed_packet=100M" innodb_file_per_table: content: "[mysqld]\ninnodb_file_per_table" query_cache_size: content: "[mysqld]\nquery_cache_size = 128M" table_open_cache: content: "[mysqld]\ntable_open_cache = 2048" memory_buffers: content: "[mysqld]\ntmp_table_size = 128\nmax_heap_table_size = 128M\njoin_buffer_size = 1M\nmyisam_sort_buffer_size = 8M\nsort_buffer_size = 2M"

php::modules: xdebug: pkgname: "pecl-xdebug" zend: "/usr/lib64/php/modules" settings: xdebug.remote_enable: 1 xdebug.remote_connect_back: 1 xdebug.remote_handler: "dbgp"

---forumone::databases: web: username: web

forumone::webserver::vhosts: vagrant: path: "/vagrant/public"

forumone::php::prefix: "php53u"

forumone::solr::collections: drupal: order: 1

Server Platform Site

Monday, April 14, 14