15
More Modern Perl With Docker Jason (Jayce^) Hall - BlueHost [email protected]

More Modern Perl - YAPC 2016

Embed Size (px)

Citation preview

More Modern PerlWith DockerJason (Jayce^) Hall - BlueHost [email protected]

What is Modern Perl?How can you get more modern?

What is Modern Perl?New VersionsUpdate CyclesNew Tools

a renaissancefrequency, but you need to update

But we already have tools for thatperlbrewplenvcartonSoftware Collections

Does not remove usefulness of any of these, in fact can make them even more usefultest your code against multiple versionbut you have to compile and maintain each one

Carton get the modules you use - if it works in your toolchainSCL - Redhat/centos RPM based custom environments

Why beyond Hipster reasons?

The Absolute BasicsContainersJust what you needEncourage small services

Not for full VMs really, look at the upcoming vagrant talk for thatThe next generation of architectureSlice out just the parts you need from a VMLess exposureLess data to cart around

Pre Built ImagesDocker PerlPick your baseOptimize

Basic containers with just the engine you want to tryPerl latestspecific perl versions, options (eg threading)and yes, perl6

Beyond the beginningREPL is nifty, butI want a current perlTo run this code I haveAnd add my deps

What comes in the image? NOTHING..You need to start adding thingsso you can DO things, who programs without CPAN?

First NoteYou can build up an image and save your whole appDocker run, Add your needs, runOr have a common base that just mounts your application codedocker build / tag / pushRegistry Server

grab the basic and play, start adding in modules you usesave out your state, to use for laterHave your script pull in what it needsBetter, set one up with *your* use case, and start from that point

Running our first codePick our imageMount our code directoryInstall depsProfit

Have the base commands in the imageSee, its that easy.Interactive terminalClean up our container after ourselvesMount my project directory under /appwhich image am I based off ofWhat command do I run?could be dzil authordeps | cpanm, or carton run

DockerfileFROMENVRUNWORKDIREXPOSECMD

Well, who wants to build up that command line every time?Build your arguments, and extra features into a fileStartup your app, process, etc just by feeding your file into dockerBuild an image with your common starting point, or your final productDocker pages have plenty of info and examples about better practices, such as && and working with image layersDefault command (my REPL in this case) but overrides with command line usage

Some OptimizationsWhich Base imageChain CommandsClean up work infoBuild in your dependenciesBuild on other images

Standard Perl library was > 750mb! If Im running a container that is *only* the things I *need* it shouldnt have to be that large!Current standard starts at 255 - 285 mbBuilt one off of Alpine and it was 75mb

Interacting with othersDocker-composeManagement interfaceHostname setupService groupsRuntime options

What if you wanted to describe multiple containers at once? Docker file for a system of containersGet them to know how to interact with each otherAll your docker command line argumentsAutomate a systemDefine private network spaceOther toolsDefine custom locations, registry servers

Pullupdatebuildrunlog

I can reference by name : so refer to mongo or redis box in their DSN

Automating a systemCompose your alpha/beta/stageBuild your images runtime readyUpgrade to other toolsAWSKubernetesocean of others

docker-composeLocal boxcan push build elsewhereor quickly use prebuilt images to replicateincluding out to live - please learn when this is right (eg not db)

Johnny DoeBut What About A Live Demo

RedisMongoAPIWorker

More Modern PerlWith DockerJason (Jayce^) Hall - BlueHost [email protected]

What is Modern Perl?How can you get more modern?