Automating web site deployment

15
gareth rushgrove | morethanseven.net Automating Web Site Deployment No more FTP Barcamp Brighton 5th September 2009 http://www.flickr.com/photos/grittycitygirl/186837530/

description

You really should automate the deployment of your web site or application. Stop using your source control system for deployment, and definitely stop relying on FTP. This presentations talks about why, what you should be doing and importantly how to go about doing it.Presented at barcamp brighton 4

Transcript of Automating web site deployment

Page 1: Automating web site deployment

gareth rushgrove | morethanseven.net

Automating Web Site Deployment No more FTP

Barcamp Brighton 5th September 2009

http://www.flickr.com/photos/grittycitygirl/186837530/

Page 2: Automating web site deployment

Gareth Rushgrove

gareth rushgrove | morethanseven.net

morethanseven.net

Page 3: Automating web site deployment

What do you do now?

gareth rushgrove | morethanseven.net http://www.flickr.com/photos/mn_francis/392404523/

Page 4: Automating web site deployment

- Put all files under sourcecontrol

- Move files to the server

- Copy configuration into place

- Symlink the current release

- Restart your webserver

gareth rushgrove | morethanseven.net

Steps to deploy

Page 5: Automating web site deployment

gareth rushgrove | morethanseven.net

Put all files under sourcecontrol

http://www.flickr.com/photos/rooreynolds/2396418896/

Page 6: Automating web site deployment

gareth rushgrove | morethanseven.net

Move all files to the server

Don't just FTP files to the server

- Anything manual is error prone

- You will miss an important file

- Deploying to multiple machines at once is hard

- You have no history, what was live a year ago?

Page 7: Automating web site deployment

gareth rushgrove | morethanseven.net

Move all files to the server II

Don't checkout your repo and serve from that.

- Your web servers need access to your repository

- You have to remember to limit access to hidden files

- Not all commands are atomic

- The checkout can become corrupt

Page 8: Automating web site deployment

gareth rushgrove | morethanseven.net

Move all files to the server III

Do use some sort of package.

- Tar files are fine, deb files are great

- It's repeatable

- You can introspect packages

- Packages freeze a moment in time

Page 9: Automating web site deployment

gareth rushgrove | morethanseven.net

Copy configuration into place

For example:

- Apache virtualhosts

- Memcache configuration

- Solr configuration

- Anything that lives in /etc in debian

Page 10: Automating web site deployment

gareth rushgrove | morethanseven.net

Symlink the current release

- Each release is stored in a unique named directory

- You could use a timestamp or a version control uid

- A symlink points at the directory

- Apache virtualhosts point at the symlink

Page 11: Automating web site deployment

> cd /srv/sample; lspackages releases shared

> cd packages; ls20090905142306.tar.gz

> cd ../releases; ls20090905142306 current

gareth rushgrove | morethanseven.net

Symlink the current release II

Page 12: Automating web site deployment

gareth rushgrove | morethanseven.net

Restart your web server

http://www.flickr.com/photos/anonymouscollective/2291896028/

Page 13: Automating web site deployment

gareth rushgrove | morethanseven.net

WARNING: Live Demo

http://www.flickr.com/photos/arthur_chapman/3855590323/

Page 14: Automating web site deployment

gareth rushgrove | morethanseven.net

Next steps

You’ll probably want to move onto:

- Creating databases, or running migrations

- Rollback to a previous version

- Deploy to multiple machines at once

- Installing third party libraries

Page 15: Automating web site deployment

http://www.flickr.com/photos/jasephotos/1736694514/in/photostream/gareth rushgrove | morethanseven.net

Questions?