@mheap
1. Easy setup
2. One-click deployments
3. Environment support
4. Can only deploy from repo
1. Files copied one by one
2. Composer run on server
3. No build steps
4. Their way, or the highway
5. Can’t deploy if provider is
offline
Pros Cons
@mheap
$ cat config/deploy.rb
lock '3.6.1'
set :application, 'silex_todo'
set :repo_url, 'git@github.com:mheap/fake-todo-app.git'
set :deploy_to, '/var/www/todo'
@mheap
$ cap production deploy
Generate and upload deployment script
Clone repo
Generate archive from repo
Untar archive into releases folder
Symlink current folder to the latest release
Slide 50
Slide 50 text
@mheap
$ gem install capistrano-composer
In Capfile:
require 'capistrano/composer'
Slide 51
Slide 51 text
@mheap
$ cap production deploy
00:18 composer:run
01 composer install --no-dev --prefer-dist --no-interaction --
quiet --optimize-autoloader
✔ 01 deploy@todo.example 1.023s
Slide 52
Slide 52 text
@mheap
lib/capistrano/tasks/database_tasks.rake:
namespace :database do
desc 'migrate database'
task :migrate do
on roles(:db) do
execute "cd #{release_path} && ./vendor/bin/
doctrine-migrations migrations:migrate --db-configuration
config/db-config.php --configuration config/migrations.yml"
end
end
end
Slide 53
Slide 53 text
@mheap
lib/capistrano/tasks/database_tasks.rake:
namespace :database do
desc 'migrate database'
task :migrate do
on roles(:db) do
execute "cd #{release_path} && ./vendor/bin/
doctrine-migrations migrations:migrate --db-configuration
config/db-config.php --configuration config/migrations.yml"
end
end
end
Slide 54
Slide 54 text
@mheap
lib/capistrano/tasks/database_tasks.rake:
namespace :database do
desc 'migrate database'
task :migrate do
on roles(:db) do
execute "cd #{release_path} && ./vendor/bin/
doctrine-migrations migrations:migrate --db-configuration
config/db-config.php --configuration config/migrations.yml"
end
end
end
Slide 55
Slide 55 text
@mheap
lib/capistrano/tasks/database_tasks.rake:
namespace :database do
desc 'migrate database'
task :migrate do
on roles(:db) do
execute "cd #{release_path} && ./vendor/bin/
doctrine-migrations migrations:migrate --db-configuration
config/db-config.php --configuration config/migrations.yml"
end
end
end
Slide 56
Slide 56 text
@mheap
lib/capistrano/tasks/database_tasks.rake:
namespace :database do
desc 'migrate database'
task :migrate do
on roles(:db) do
execute "cd #{release_path} && ./vendor/bin/
doctrine-migrations migrations:migrate --db-configuration
config/db-config.php --configuration config/migrations.yml"
end
end
end
Slide 57
Slide 57 text
@mheap
Capfile:
after "composer:install", "database:migrate"
Slide 58
Slide 58 text
@mheap
$ cap production deploy
00:22 database:migrate
01 cd #{release_path} && ./vendor/bin/doctrine-migrations
migrations:migrate —db-co…
✔ 01 deploy@todo.example 0.812s
@mheap
1. One-click deployments
2. Environment support
3. Can only deploy from repo
4. Internal solution
5. Atomic deploys
6. Rollback support
1. Learning curve
2. Composer run on server
3. No build steps
4. Probably want to use
Bundler to manage versions
Pros Cons
Slide 62
Slide 62 text
@mheap
Option C: System Packages
Slide 63
Slide 63 text
@mheap
$ apt-get install todo
$ yum install todo
$ pacman -S todo
@mheap
$ fpm -s dir -t rpm --config-files /etc --exclude
"var/www/todo/config*" -n todo src/=/var/
www/todo src/config/=/etc/todo
=> Created package
{:path=>"todo-1.0-1.x86_64.rpm"}
Slide 72
Slide 72 text
@mheap
Continous Integration
Slide 73
Slide 73 text
@mheap
What is
Continous Integration?
Slide 74
Slide 74 text
@mheap
Use it to
run tests
Slide 75
Slide 75 text
@mheap
Use it to
composer install
Slide 76
Slide 76 text
@mheap
Use it to
mitigate risk
Slide 77
Slide 77 text
@mheap
Use it to
build on identical platforms
Slide 78
Slide 78 text
@mheap
Use it to
package your application
Slide 79
Slide 79 text
@mheap
Use it to
deploy to production
Slide 80
Slide 80 text
@mheap
Use it to
AUTOMATE THINGS
Slide 81
Slide 81 text
@mheap
@mheap
Slide 82
Slide 82 text
@mheap
Option C: System Packages
Slide 83
Slide 83 text
@mheap
$ apt-get install todo
$ yum install todo
$ pacman -S todo
Slide 84
Slide 84 text
@mheap
Almost
Slide 85
Slide 85 text
@mheap
Database migrations
Slide 86
Slide 86 text
@mheap
$ fpm -s dir -t rpm --config-files /etc --exclude
"var/www/todo/config*" -n todo src/=/var/
www/todo src/config/=/etc/todo
=> Created package
{:path=>"todo-1.0-1.x86_64.rpm"}
Slide 87
Slide 87 text
@mheap
$ fpm -s dir -t rpm --config-files /etc --exclude
"var/www/todo/config*" -n todo
--after-install /path/to/script src/=/var/www/
todo src/config/=/etc/todo
=> Created package
{:path=>"todo-1.0-1.x86_64.rpm"}
Slide 88
Slide 88 text
@mheap
Useful tools
FPM
Jenkins
RPM / Deb / Pkg
Slide 89
Slide 89 text
@mheap
Releases are
immutable
Slide 90
Slide 90 text
@mheap
1. Atomic releases
2. Build on system tools
3. Proper build toolchain
4. Signed builds
5. Easy upgrade/rollback
6. Immutable
1. Steep learning curve
2. Need to run package repo
3. Ideal to run CI system
Pros Cons
Slide 91
Slide 91 text
@mheap
Option D: Blue / Green
Slide 92
Slide 92 text
@mheap
Load
Balancer
Slide 93
Slide 93 text
@mheap
Load
Balancer
Slide 94
Slide 94 text
@mheap
Shared databases
Slide 95
Slide 95 text
@mheap
Single database
Slide 96
Slide 96 text
@mheap
Server maintenance
Slide 97
Slide 97 text
@mheap
Shameless Plug
Slide 98
Slide 98 text
@mheap
Infrastructure level
Slide 99
Slide 99 text
@mheap
Useful tools
Puppet / Chef / Ansible
HAProxy
Slide 100
Slide 100 text
@mheap
1. Low risk deployments
2. Test on production systems
3. Easy changeover
1. Can be expensive
2. Databases are hard
3. More moving parts to
manage
Pros Cons