44
PaaSing Your Code Around EMAIL: [email protected] TWITTER: @DRAGONMANTANK O c t 8 2 0 1 3 Z e n d C o n 2 0 1 3 1

PaaSing Your Code Around

  • Upload
    elam

  • View
    21

  • Download
    3

Embed Size (px)

DESCRIPTION

PaaSing Your Code Around. Email: [email protected] 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. - PowerPoint PPT Presentation

Citation preview

Page 1: PaaSing  Your Code Around

ZendCon 20131

PaaSing Your Code Around

EMAIL: [email protected]: @DRAGONMANTANK

Oct 8 2013

Page 2: PaaSing  Your Code Around

ZendCon 20132Who 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/dragonman

tank

Oct 8 2013

Page 3: PaaSing  Your Code Around

ZendCon 20133

What is PaaS?

Oct 8 2013

Page 4: PaaSing  Your Code Around

ZendCon 20134

Software as a Service (SaaS)

Software Package

Platform as a Service

Platform as a Service (PaaS)

Server Language Deployment Scripts

Infrastructure as a Service (IaaS)

Server Infrastructure Storage Network

Oct 8 2013

Page 5: PaaSing  Your Code Around

ZendCon 20135Why 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

Oct 8 2013

Page 6: PaaSing  Your Code Around

ZendCon 20136PaaS Workflow

Git repo

Feature Branch

Feature Branch

Feature Branch

Run Paas Deployment

Your App Runs!

Oct 8 2013

Page 7: PaaSing  Your Code Around

ZendCon 20137Basic 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

Oct 8 2013

Page 8: PaaSing  Your Code Around

ZendCon 20138Other Considerations

Where will uploaded files live? Does my app scale across multiple servers? How well does my application perform? Can I automate everything?

Oct 8 2013

Page 9: PaaSing  Your Code Around

ZendCon 20139

Oct 8 2013

Page 10: PaaSing  Your Code Around

ZendCon 201310Let’s set up a site on a

PaaS https://github.com/dragonmantank/paasing-you

r-code-around

Oct 8 2013

Page 11: PaaSing  Your Code Around

ZendCon 201311What I built

Silex App that displayed user-supplied ‘texts’ from drunk elephants Silex Symfony Forms Ruckusing Migrations Twig

Oct 8 2013

Page 12: PaaSing  Your Code Around

ZendCon 201312What 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

Oct 8 2013

Page 13: PaaSing  Your Code Around

ZendCon 201313What I did

Created the basic app in vagrant Signed up for a PaaS

Heroku Engineyard Redhat OpenShift 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

Oct 8 2013

Page 14: PaaSing  Your Code Around

ZendCon 201314

Heroku

Oct 8 2013

Page 15: PaaSing  Your Code Around

ZendCon 201315Heroku

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

Oct 8 2013

Page 16: PaaSing  Your Code Around

ZendCon 201316Heroku – Creating an

Application Oct 8 2013

Page 17: PaaSing  Your Code Around

ZendCon 201317Heroku – Deploying an

App Push your branch to Heroku’s master branch

Oct 8 2013

Page 18: PaaSing  Your Code Around

ZendCon 201318Heroku – 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

Oct 8 2013

Page 19: PaaSing  Your Code Around

ZendCon 201319Heroku – 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

Oct 8 2013

Page 20: PaaSing  Your Code Around

ZendCon 201320

Engineyard

Oct 8 2013

Page 21: PaaSing  Your Code Around

ZendCon 201321Engineyard

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

Oct 8 2013

Page 22: PaaSing  Your Code Around

ZendCon 201322Engineyard – 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

Oct 8 2013

Page 23: PaaSing  Your Code Around

ZendCon 201323Engineyard – Deploying

an App Give it a branch name and click ‘Deploy’

Oct 8 2013

Page 24: PaaSing  Your Code Around

ZendCon 201324Engineyard – Getting it to

Work Had to add a deploy/ script to get the database

migrations to work

Oct 8 2013

Page 25: PaaSing  Your Code Around

ZendCon 201325Engineyard – 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!

Oct 8 2013

Page 26: PaaSing  Your Code Around

ZendCon 201326

Redhat OpenShift

Oct 8 2013

Page 27: PaaSing  Your Code Around

ZendCon 201327OpenShift

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

Oct 8 2013

Page 28: PaaSing  Your Code Around

ZendCon 201328OpenShift – Creating an

Application Oct 8 2013

Page 29: PaaSing  Your Code Around

ZendCon 201329OpenShift – Deploying an

App Push your branch to OpenShift’s master branch

Oct 8 2013

Page 30: PaaSing  Your Code Around

ZendCon 201330OpenShift– 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

Oct 8 2013

Page 31: PaaSing  Your Code Around

ZendCon 201331OpenShift – 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

Oct 8 2013

Page 32: PaaSing  Your Code Around

ZendCon 201332

AWS ElasticBeanstalk

Oct 8 2013

Page 33: PaaSing  Your Code Around

ZendCon 201333ElasticBeanStalk

It’s a Rackspace-based PaaS!

Oct 8 2013

Page 34: PaaSing  Your Code Around

ZendCon 201334ElasticBeanStalk

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

Oct 8 2013

Page 35: PaaSing  Your Code Around

ZendCon 201335ElasticBeanstalk –

Creating an Application Log in AWS and go to ElasticBeanstalk Create an Application through their ‘eb’ tool

Go to your repo Run ‘eb init’ and answer the questions

Oct 8 2013

Page 36: PaaSing  Your Code Around

ZendCon 201336ElasticBeanstalk –

Deploying an App Run ‘eb branch’ to assign your branch to an

environment Run ‘git aws.push’ to deploy

Oct 8 2013

Page 37: PaaSing  Your Code Around

ZendCon 201337ElasticBeanstalk –

Getting it to Work Had to run ‘eb init’ 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 ‘git aws.push’ would work

Oct 8 2013

Page 38: PaaSing  Your Code Around

ZendCon 201338ElasticBeanstalk –

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

Oct 8 2013

Page 39: PaaSing  Your Code Around

ZendCon 201339

So What did I Learn?

Oct 8 2013

Page 40: PaaSing  Your Code Around

ZendCon 201340Deploy 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

Oct 8 2013

Page 41: PaaSing  Your Code Around

ZendCon 201341Understand 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

Oct 8 2013

Page 42: PaaSing  Your Code Around

ZendCon 201342Your 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

Oct 8 2013

Page 43: PaaSing  Your Code Around

ZendCon 201343Questions?

Oct 8 2013

Page 44: PaaSing  Your Code Around

ZendCon 201344Thank You!

[email protected] @dragonmantank https://joind.in/9070

Oct 8 2013