professional workflow from development to deployment
TRANSCRIPT
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Rachel Andrew
http://rachelandrew.co.uk
@rachelandrew
http://grabaperch.com
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Many issues coming into support stem from poor development and deployment processes.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
The Big Problems
• Developing directly on live sites or in subfolders of live sites
• Developing in subfolders locally
• Setting up local development environments that are so different to the eventual live server that there is no confidence when going live
• Deploying via FTP piecemeal and having sites blow up due to missing files
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
What’s the problem with (S)FTP?
• You are transferring files one by one to the server with no management of that transfer
• One failed transfer can break the site
• Old files may be left on the server - this could be a security risk in the case of third party software
• Very hard to debug issues caused by missing files especially where they are deep in third party code
Forrest Gump
“you’ve got to put the past behind you before you can move on.”
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Improving workflow is the best way to give yourself more hours in the day.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
These are baby steps to improved workflow.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
We need …
• to develop multiple websites on our own computer.
• to know that our live server and local server support the same things.
• to deploy our site and have confidence that what is on the live server is identical to our local version.
• to allow clients to view a site in progress during initial development and also when making changes in future.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy @rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Working locally
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Developing live on the server!
• High chance of making a change that breaks something about the site.
• No way for the client to preview changes
• Local version in sync? Do we even have a local version?
• If you get to the beach, you’ll be fixing a website. On your phone. Have fun with that.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Q. How do you deploy your sites to the server?
A. We just edit on the server directly.
8%
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Let’s develop in a subfolder!
• Create a ‘newsite’ subfolder and develop the site there
• Potential to make an accidental change to the live site with an FTP mishap
• If the site is in a subfolder then it doesn’t replicate the live site. To go live you have to change all of your file paths.
• You are not going to the beach. You are fixing up file paths. More fun!
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
File paths and URLs are fundamental to the web. Changing them on going live is messy
and fragile.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Developing remotely is going to be a slow way to work.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Mac Users - install Apache, PHP and MySQL on your machine.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
homebrew.sh
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
MAMP, XAMPP, WAMP
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Q. How do you develop sites locally that require a web server?
A. MAMP, WAMP, XAMPP or similar
63%
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Linux
Apache
MySQL
PHP
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Take your pick
• Mamp - https://www.mamp.info/en/
• Wamp - http://sourceforge.net/projects/wampserver/
• Xampp - https://www.apachefriends.org
• EasyPHP - http://www.easyphp.org/
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
VirtualHosts - many websites on one server
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Avoid creating your own local version of developing in a subfolder. Remember - we
don’t want to change file paths to go live!
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
https://www.mamp.info/en/mamp-pro/
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Access multiple sites at client1.dev, client2.dev
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
In an ideal world your local development environment is identical to the live server.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://php.net/manual/en/function.strftime.php
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
PHP Versions can be different. PHP modules may not be available on the live server.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Virtual Machines
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
virtualbox.org
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
vagrantup.com
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
https://puphpet.com
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://rachelandrew.co.uk/presentations/deploy/puphpet
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Upload a PHP file with this function to find out what is available on your live server.
<?php phpinfo();?>
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Things to check on your live server
• PHP Version
• Installed modules such as gd for image processing
• post_max_size and upload_max_filesize determine the size of files that can be uploaded
• max_input_vars is the number of form fields allowed in a post
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Shared Folders
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy @rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Basic commands for Vagrant.
// start the VM > vagrant up
// shut down the VM > vagrant halt
//destroy the VM > vagrant destroy
//ssh access > vagrant ssh
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://vagrantmanager.com/
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Share your package with anyone else working on the site. The whole team can then have the
exact same development setup.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
We want …
to develop multiple websites on our own computer
to know that our live server and local server support the same things
to deploy our site and have confidence that what is on the live server is identical to our local version
to allow clients to view a site in progress
to leave work early and go to the beach.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://github.com
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://beanstalkapp.com
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
If you already have files you need to add to a git repository.
cd my-git-repo
git remote add beanstalk [email protected]:/gitreponame.git
git push beanstalk
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
If you are starting a new project.
git clone https://accountname.git.beanstalkapp.com/gitreponame.git -o beanstalk
cd gitreponame
echo "This is my new project on Beanstalk." > README
git add README
git commit -m "My first commit."
git push beanstalk master
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
www.git-tower.com
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
www.git-tower.com/learn/ebook
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
A branch is a version of your site. We are deploying the master branch to live.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Production refers to your live site. Staging a site where changes are tested and previewed.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
We make a change to our files, commit and push them to Beanstalk. The Master Branch now contains only what should be deployed.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Deploy all the things
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Deployment with Beanstalk
• Deployments can be Manual or Automatic
• Automatic deployments happen when code is pushed to the branch you are deploying
• Manual deployments are triggered by you at Beanstalk once you are happy to go live
• Once a deploy happens Beanstalk makes sure the code on the live site matches that in Git, removing deleted files, replacing modified ones and adding new files
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
On Deploy
• Beanstalk connects to your server
• ensures that the files on the server match the files in the branch you are deploying
• on initial deploy all existing files on the server have to be checked. Your first deploy will be slow!
• subsequent deploys only change things that have changed in git.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Deployment Tips
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Create multiple server configuration files
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://solutions.grabaperch.com/development/multiple-server-config
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Use .gitignore to keep things out of Beanstalk
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
https://github.com/github/gitignore
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Our new workflow.
1. Edit files as usual on your computer
2. View your site via a web server on that computer
3. Commit changes to Git
4. Push to Beanstalk
5. Login to Beanstalk and hit Deploy
6. Go to the beach.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Databases and Uploaded Assets
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Add CMS managed asset folders to a .gitignore file so they are not committed
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Use a CDN for assets if your CMS enables it. Faster download speeds with bonus ease of
management across environments.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Initial deploy to live also involves an export and import of the MySQL database.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
How to deal with schema or even data changes on an existing site?
How do you manage database changes between development and live?
“try to keep live db current, and keep list of changes in settings on dev environment. this is the one thing that needs a better solution in my development workflow, esp. when working together with other developers on one project.”
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
How do you manage database changes between development and live?
“Labour intensively. Save a dump of the live version. Then compare the structure of the development and live structures in a diff checker. Finally make the updates required on the live version, importing the new data. ”
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Create a Maintenance Window where no changes are made to live.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
https://deliciousbrains.com/wp-migrate-db-pro/
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
http://www.navicat.com/products/navicat-for-mysql
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
We want …
to develop multiple websites on our own computer
to know that our live server and local server support the same things
to deploy our site and have confidence that what is on the live server is identical to our local version
to allow clients to view a site in progress
to leave work early and go to the beach.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
A Staging Server
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Using an inexpensive VPS you can create sites at clientname.yourcompany.com for preview.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
You can deploy the master branch to staging to check before deploying to production.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Even better, you can use your staging server to deploy commits to a staging branch.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Deploy with a tag to any commit or push comment. For example: [Deploy: Staging]
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Try to keep your Master branch deployable to live. If disaster strikes you can redeploy.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Remember to backup your database and any resources regularly!
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Logging in and downloading the assets when you remember is not a backup strategy.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Bonus feature! We can now easily switch hosting if our current host becomes unreliable.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Unsolved problems
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
There are product opportunities in helping people in shared PHP hosting land navigate
these issues.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Pre and post-processed CSS and JavaScript files.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Backup of CMS-managed resources
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Database migrations
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
We want …
to develop multiple websites on our own computer
to know that our live server and local server support the same things
to deploy our site and have confidence that what is on the live server is identical to our local version
to allow clients to view a site in progress
to leave work early and go to the beach.
@rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy @rachelandrew | Read more at http://rachelandrew.co.uk/presentations/deploy
Thank you!
Slides & resources at:http://rachelandrew.co.uk/presentations/deploy
@rachelandrew