"Docker For Polyglots" - Nathan LeClaire - YAPC::Asia 2015

Post on 16-Jan-2017

703 views 0 download

transcript

DOCKER FOR POLYGLOTSNathan LeClaire, Open Source Engineer at Docker Inc.

WELCOME

• I appreciate your participation ! To speak at this conference is an honor.

• Today we are going to talk about "Docker For Polyglots".

• A "polyglot" is someone who speaks multiple languages.

THANK YOU FOR CONFERENCE

WHO AM I?Nathan LeClaire (@upthecyberpunks)

Open Source Engineer, Docker Machine

I ❤ JAPAN

TOOLS OF MASSIVE INNOVATION

TOOLS OF MASSIVE INNOVATION

LET'S LOOK AT SOME FACTS

FACT: VARIETY

• Developers want to use a variety of programming languages

• "The right tool for the right job"

• This complicates the process of setting up development environments and running operations

FACT: TECHNOLOGY CHANGES RAPIDLY• Front end web development alone has a huge

explosion of options including SASS, Grunt, Yeoman, etc.

• Not every developer on your team is going to be an expert in tooling for every language but they still might want to contribute

• More friction == less productivity

FACT: TOOLING IS DIFFICULT

• For instance, Maven might be intimidating to a Go developer.

• Python programmers might want to use Ruby sometimes but don't know how to use rbenv or rvm

• Contributing to open source is very difficult for this reason.

FACT: "BUS FACTOR" RISK IS HIGH

• If "the person who sets up the environments" on your team was hit by a bus tomorrow, would it be easy or hard to keep going?

• Can any person on your team destroy their development environment and re-build it from scratch automatically?

FACT: DEPENDENCY HELLDoes this type of thing look familiar?

DOCKER CAN HELP

• Docker provides a way of distributing applications

• It also provides orchestration tools for developing them

• End game is to reduce friction to the point where transitioning between projects is seamless

MY DREAM: SIMPLICITY

MY DREAM: UNIFORMITY

MY DREAM: PHOENIX DEVELOPMENT

WHAT IS A POLYGLOT?"PROGRAMMING LANGUAGE"

WHAT IS A POLYGLOT?"TOOLING LANGUAGE"

WHAT IS A POLYGLOT?"DEVELOPER LANGUAGE"

"We need to add some migrations to run for the database, a few

controllers, and also some jobs to run in the background queue."

WHAT IS A POLYGLOT?"OPERATOR LANGUAGE"

"Let's set up some automation around our load balancers, store these files in an S3 bucket and consider moving to a cross-cloud solution with overlay networking."

DOCKER LETS YOU DEFINE AN ENVIRONMENT SIMPLY

EXAMPLE

I DON'T KNOW ANYTHING ABOUT LUA...

...AND ONLY A LITTLE ABOUT NGINX.

SETTING UP OPENRESTY MANUALLY

$ sudo apt-get install -y make build-essential libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl make build-essential

$ # Go to browser, click around on "Download Page"

$ wget https://openresty.org/download/ngx_openresty-1.9.3.1.tar.gz

$ tar xvf ngx_openresty-1.9.3.1.tar.gz

$ cd ngx_openresty-1.9.3.1

$ ./configure; make; make install

FORTUNATELY THAT PROJECT HAS GOOD DOCUMENTATION,

BUT WHAT IF IT DIDN'T?

WHAT IF YOU WANT TO INSTALL AUTOMATICALLY ON ANOTHER COMPUTER?

OR EASILY SHARE YOUR APPLICATION WITH A FRIEND OR COLLEAGUE?

REPLACE MANUAL METHOD WITH A TINY BASH SCRIPT?

"YEAH, I KNOW YOU DEVELOP ON DEBIAN, BUT THIS NEEDS TO RUN ON

RHEL."

DEVELOPER

Installing software is boring! I just want to script nginx with Lua!

SOLUTION

WE CAN MAKE DOCKERFILE.IT WILL RUN ON ANY OS WITH

COMPATIBLE KERNEL.from debian:jessie

run apt-get update run apt-get install -y \ libreadline-dev \ libncurses5-dev \ libpcre3-dev \ libssl-dev \ perl \ wget \ make \ build-essential run mkdir -p /openresty workdir /openresty env OPENRESTY_VERSION 1.7.10.2 run wget http://openresty.org/download/ngx_openresty-${OPENRESTY_VERSION}.tar.gz run tar xzvf ngx_openresty-${OPENRESTY_VERSION}.tar.gz run cd ngx_openresty-${OPENRESTY_VERSION}/ && \ ./configure && \ make && \ make install env PATH /usr/local/openresty/nginx/sbin:$PATH add https://get.docker.com/builds/Linux/x86_64/docker-latest /docker run chmod +x /docker add . /app workdir /app entrypoint ["./entrypoint.sh"]

BUILD, SHIP, & RUN

$ docker build -t nathanleclaire/openresty . $ docker push nathanleclaire/openresty $ # Now we can pull from anywhere! $ # On another computer... $ docker run -d -P nathanleclaire/openresty

YOU CAN USE AUTOMATED BUILDS ON DOCKER HUB TO LEARN FROM OTHER

PEOPLE

LOTS OF CONTRIBUTION TO DOCKER BECAUSE OF DOCKER

DOCKER MACHINE

DOCKER COMPOSE

DOCKER SWARM