How we automated our Drupal deployment process at onsavvy.com with Git and Capistrano. First presented at Drupal Show and Tell, 15 August 2013, London.
2. About this session
Git+Capistrano for deployment
Mainly Capistrano
Overview - not too detailed
Input/feedback/questions from you guys
Lots of info online - links at the end
3. Show of hands please...
Some sort of automated deployment process
Git and Capistrano
Git only + SSH
FTP/SFTP
Aegir?
Drush?
Pantheon?
No idea!
13. Why capistrano
Looked at a few options (git hooks, Jenkins,
capistrano)
capistrano - simple, does the job for us
Drupal deploy scripts available (capdrupal,
capistrano-drupal)
19. How to deploy
1. Make local changes
2. git commit and push
3. $ “cap deploy”
That’s it
20. What “cap deploy” does
SSH into server
Takes site offline
Backup of db (using drush & backup_migrate)
Clones latest revision from dev branch
Points site root to that latest clone
Runs update db
Reverts features
Clears cache
Puts site back online
21. Directory structure on server
current -> releases/20130805211651 (symlink)
releases/
20130801135258
20130805211547
20130805211651
shared/
cached-copy/
files/
settings.php
NB: running “cap deploy:setup” creates the dir structure
22. Before “cap deploy”
current -> releases/20130805211651
releases/
20130801135258
20130805211547
20130805211651
shared/
cached-copy/
files/
settings.php
23. After “cap deploy”
current -> releases/20130805212640 (points to new clone)
releases/
20130801135258
20130805211547
20130805211651
20130805212640 <- new git clone
shared/
cached-copy/
files/
settings.php
24. Local directory structure
app/ <- drupal root
config/
deploy.rb <- project specific settings
dev.rb <- site specific settings
live.rb
Capfile
29. Customisations to Capdrupal
“backup db”, “update db”, “revert features”
= not relevant when only updating CSS
so we removed them from deploy task
can be run by themselves when needed
31. Potential improvements
Create backups of db, that can be rolled back
(e.g new copy of db and settings.php for each
new deploy)
Fully automated deployment, continuous
integration
32. References
YouTube:
- Simple and powerful site deployment with capistrano - by
Kim Pepper - http://youtu.be/ulK-lhv8eI0
- DrupalCon Munich 2012: Deploy with Capistrano - by
Michael Priest - http://youtu.be/fvkiWfjmKQ4
Github:
https://github.com/antistatique/capdrupal
https://github.com/previousnext/capistrano-drupal
https://github.com/capistrano
Google capistrano drupal
33. Feel free to get in touch
Farez Rahman
slideshare.net/onsavvy
onsavvy.com/profile/farez-rahman
d.o: user/261497
Twitter: farez
farez @ redkeydigital.com