1 / 44

PaaSing Your Code Around

PaaSing Your Code Around. Email: Chris@ctankersley.com Twitter: @ dragonmantank. Who Am I?. Chris Tankersley Been Doing PHP for 9+ Years Lots of projects no one uses, and a few that some do: https://github.com/dragonmantank. What is PaaS ?. Platform as a Service.

elam
Download Presentation

PaaSing Your Code Around

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. PaaSing Your Code Around ZendCon 2013 Email: Chris@ctankersley.com Twitter: @dragonmantank

  2. Who Am I? • Chris Tankersley • Been Doing PHP for 9+ Years • Lots of projects no one uses, and a few that some do: • https://github.com/dragonmantank ZendCon 2013

  3. What is PaaS? ZendCon 2013

  4. Platform as a Service Software as a Service (SaaS) Software Package Platform as a Service (PaaS) ZendCon 2013 Server Language Deployment Scripts Infrastructure as a Service (IaaS) Server Infrastructure Storage Network

  5. Why use a PaaS? • Offload the work to someone else • Possibly (maybe) more cost effective • Small shops don’t have to hire as many people • Scalability, both up and down ZendCon 2013

  6. PaaS Workflow Your App Runs! ZendCon 2013

  7. Basic Knowledge • Just about all of them use git • Just about all of them work best with a command line • Your OS doesn’t matter, they all pretty much support everything • A server-side scripting language • Bash, Ruby, Python ZendCon 2013

  8. Other Considerations • Where will uploaded files live? • Does my app scale across multiple servers? • How well does my application perform? • Can I automate everything? ZendCon 2013

  9. ZendCon 2013

  10. Let’s set up a site on a PaaS • https://github.com/dragonmantank/paasing-your-code-around ZendCon 2013

  11. What I built • Silex App that displayed user-supplied ‘texts’ from drunk elephants • Silex • Symfony Forms • Ruckusing Migrations • Twig ZendCon 2013

  12. What did I want to find out? • How much code I had to change to get it to work • How much of a pain was it to get the deployment process set up • How long the deployments took • How easy the deployments were • How easy things were to manage ZendCon 2013

  13. What I did • Created the basic app in vagrant • Signed up for a PaaS • Heroku • Engineyard • RedhatOpenShift • Amazon ElasticBeanstalk • Made the app work • Each set of code is in paas/[service] • You can fork the repo, checkout the branch, and set up the config ZendCon 2013

  14. Heroku ZendCon 2013

  15. Heroku • Heroku is a container-based PaaS • Each container (dyno) is a little virtualized environment • “Supports” PHP 5.3.27 and Apache 2.2.25 out of the box • Has a command line interface for working with your apps ZendCon 2013

  16. Heroku – Creating an Application ZendCon 2013

  17. Heroku – Deploying an App • Push your branch to Heroku’s master branch ZendCon 2013

  18. Heroku – Getting it to Work • Heroku will only detect a PHP app if there is an index.php file in the root • Docroot is automatically set to the root of your repo • PHP is supported via a partnership with Facebook, not that you’ll find that on their site • Had to add a custom Procfile, bootstrap files, and Buildpack • Composer is slooooooow. Sites took 2-15 minutes to bootstrap • Deploy hooks are done via the Procfile ZendCon 2013

  19. Heroku – General Notes • Extension support is hit or miss. You might need to compile your own • Since buildpacks actually set up an entire environment, really study what buildpack you use • Might want to commit vendor/ to your deploy branch to speed things up • While PHP 5.3.27 is the base install, you can actually install any PHP via a buildpack • Heroku uses ephemeral storage, so make sure all your files are saved to something like S3 ZendCon 2013

  20. Engineyard ZendCon 2013

  21. Engineyard • Engineyard is an AWS-based PaaS • You set up Environments, which are groups of EC2 instances • Supports PHP 5.4.17 and MySQL 5.5 out of the box • Has a command line interface for working with your apps • Works with your VCS host to pull down and deploy code ZendCon 2013

  22. Engineyard – Creating an Application • Create a new application • Select the Language • Give it a Repo to pull from • Give it a Name • Tell it the docroot • Add your deploy key to your git server • Set up an Environment • Give it a name • Give it a type (Production, Development, etc) • Select a DB • Set up SSH keys ZendCon 2013

  23. Engineyard – Deploying an App • Give it a branch name and click ‘Deploy’ ZendCon 2013

  24. Engineyard – Getting it to Work • Had to add a deploy/ script to get the database migrations to work ZendCon 2013

  25. Engineyard – General Notes • You need to set up SSH keys to get into the boxes • DB credentials are in /data/[app_name]/shared/config/databases.yml • They are also exposed through the $_SERVER array • When you stop an instance without a public IP, the IPs will change • Since it’s booting an EC2 instance, it’s slow. Takes 10-15 minutes to provision the environment (Deploys are much quicker) • Natively supports Composer! ZendCon 2013

  26. RedhatOpenShift ZendCon 2013

  27. OpenShift • OpenShift is a ‘cartridge’ (container) PaaS • Supports PHP 5.3.17 and MySQL 5.1 when using the Zend Server cartridge • Has a command line interface for working with your apps • The largest offering of platforms out of the test PaaS’s ZendCon 2013

  28. OpenShift – Creating an Application ZendCon 2013

  29. OpenShift – Deploying an App • Push your branch to OpenShift’s master branch ZendCon 2013

  30. OpenShift– Getting it to Work • Had to fetch and merge their master branch • Docroot is php/, so our deploy script changes that • php-intl extension had too old of an ICU version, so had to downgrade it through Composer • Could have completely redone PHP, like in Heroku • Composer is not natively supported, so do it via the deploy script • Deploy script is bash, so fairly easy to work with ZendCon 2013

  31. OpenShift – General Notes • You need to set up SSH keys to get into the boxes • Cartridge system is interesting and works well • Does offer persistent storage, in the $OPENSHIFT_DATA_DIR ZendCon 2013

  32. AWS ElasticBeanstalk ZendCon 2013

  33. ElasticBeanStalk • It’s a Rackspace-based PaaS! ZendCon 2013

  34. ElasticBeanStalk • It’s a Rackspace-based PaaS! • It’s an AWS-based PaaS • Supports PHP 5.4 out of the box, and Amazon RDS for DB • Has a nice command line interface ZendCon 2013

  35. ElasticBeanstalk – Creating an Application • Log in AWS and go to ElasticBeanstalk • Create an Application through their ‘eb’ tool • Go to your repo • Run ‘ebinit’ and answer the questions ZendCon 2013

  36. ElasticBeanstalk – Deploying an App • Run ‘eb branch’ to assign your branch to an environment • Run ‘gitaws.push’ to deploy ZendCon 2013

  37. ElasticBeanstalk – Getting it to Work • Had to run ‘ebinit’ and run through their setup, even though the environment existed • Had to run ‘eb branch’ to assign the current branch to an environment so that ‘gitaws.push’ would work ZendCon 2013

  38. ElasticBeanstalk – General Notes • It’s AWS, so provisioning the servers can take 10-15 minutes • Supports Composer out of the box, which is nice • Deploy hooks are done via their container_commands ZendCon 2013

  39. So What did I Learn? ZendCon 2013

  40. Deploy Scripts Are Your Friend • While you’ve got shell access, you still don’t want to do stuff manually • Knowing Bash scripting was incredibly helpful ZendCon 2013

  41. Understand Your Type of PaaS • Usually either container-based • OpenShift • Heroku • Or Server-based • ElasticBeanstalk • Engineyard • These work internally differently, so understand how each works makes your life easier ZendCon 2013

  42. Your Code Should Just Work • A good PaaS won’t need you to modify your code • My code modifications were changing DB-backends or making assumptions I shouldn’t have • Most of the differences in the sample code are deploy scripts and the config file • That’s ignoring storage issues, which you might need to work on ZendCon 2013

  43. Questions? ZendCon 2013

  44. Thank You! • chris@ctankersley.com • @dragonmantank • https://joind.in/9070 ZendCon 2013

More Related