Slide 1

Slide 1 text

DOCKER The future of web apps deployment Szymon Skórczyński Schibsted Tech Polska PHPers Tricity December 15, 2014

Slide 2

Slide 2 text

ONCE UPON A TIME…

Slide 3

Slide 3 text

TODAY

Slide 4

Slide 4 text

TOP PROBLEMS Isolation from host OS and other environments Traceability of configuration changes Portability to share with colleagues and deploy easily

Slide 5

Slide 5 text

YESTERDAY’S SOLUTION Virtualization Provisioning Orchestration

Slide 6

Slide 6 text

GOOD, BUT NOT PERFECT

Slide 7

Slide 7 text

TODAY’S SOLUTION

Slide 8

Slide 8 text

KEY FACTS • written in Go in dotCloud, a PaaS provider • became open source in March 2013 • in June 2014 released stable ver. 1.0 • current version is 1.4

Slide 9

Slide 9 text

POPULARITY angular.js laravel symfony ansible vagrant chef puppet 0 10 000 20 000 30 000 40 000 2 779 3 186 8 088 8 518 9 274 13 251 17 092 32 145 Number of stars on GitHub (November 28, 2014) docker

Slide 10

Slide 10 text

PARTNERS

Slide 11

Slide 11 text

THE METAPHOR

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

HOW DOES IT WORK?

Slide 14

Slide 14 text

THE ECOSYSTEM Image is like OVF or ISO Container is a running image Repository is a place to store images

Slide 15

Slide 15 text

THE DIFFERENCE Host OS Hypervisor Guest OS Guest OS Guest OS bins/libs bins/libs bins/libs App A App A` App B Host OS Docker bins/libs bins/libs App A App A’ App B App B’ App B’ App B’ VM Docker container Docker Standard VMs

Slide 16

Slide 16 text

ADVANTAGES

Slide 17

Slide 17 text

USAGE docker pull downloads an image docker run starts a container docker commit saves changes in an image docker push uploads an image

Slide 18

Slide 18 text

DEMO

Slide 19

Slide 19 text

LESSONS LEARNED AT SCHIBSTED

Slide 20

Slide 20 text

ISSUE #1 ONE CONTAINER

Slide 21

Slide 21 text

DOCKERFILE ### Install Supervisor RUN apt-get install -y supervisor && mkdir -p /var/log/ supervisor ADD docker/supervisord.conf /etc/supervisor/conf.d/ supervisord.conf ### Install SSH, MongoDB, PHP, Apache2, composer ### (...) CMD supervisord -c /etc/supervisor/conf.d/ supervisord.conf

Slide 22

Slide 22 text

SUPERVISORD.CONF [supervisord] nodaemon=true logfile=/var/www/phpers/app/logs/supervisord.log loglevel=debug [program:sshd] command=/usr/sbin/sshd -D [program:mongod] command=/usr/bin/mongod --smallfiles autorestart=true [program:apache2] command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2ctl -DFOREGROUND"

Slide 23

Slide 23 text

ISSUE #2 WORKING ON MAC

Slide 24

Slide 24 text

VAGRANT + DOCKER Host (MacOS) Vagrant Proxy VM (Ubuntu) Docker Container Supervisor Apache MongoDB

Slide 25

Slide 25 text

VAGRANTFILE VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.ssh.username="root" config.vm.provider "docker" do |d| d.name = "phpers" d.build_dir = "." d.ports = ["80:80", "27017:27017"] d.volumes = [ "/vagrant/:/var/www/phpers:rw", "/data/db/:/data/db:rw" ] d.vagrant_vagrantfile = "proxy/Vagrantfile.proxy" end end

Slide 26

Slide 26 text

VAGRANTFILE.PROXY VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "ubuntu/trusty64" config.vm.provision "docker" config.vm.provision "shell", inline: "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill" config.vm.network "private_network", ip: "192.168.33.12" config.vm.network "forwarded_port", guest: 80, host: 80 config.vm.network "forwarded_port", guest: 27017, host: 27017 config.vm.synced_folder "./../", "/vagrant", type: "nfs" config.vm.provider "virtualbox" do |v| v.name = "PHPers" v.memory = 2048 end end

Slide 27

Slide 27 text

+

Slide 28

Slide 28 text

ISSUE #3 THE PROCESS

Slide 29

Slide 29 text

DEVELOPERS SITE sources with dockerfile Developer GitHub build image run image

Slide 30

Slide 30 text

REMOTE SITE sources dockerfile image image sources image GitHub CircleCI AWS Docker Hub build image build with run with run with fire!

Slide 31

Slide 31 text

REMOTE SITE sources dockerfile image image with sources image GitHub CircleCI AWS Docker Hub build build image with sources run image with sources run with fire!

Slide 32

Slide 32 text

REMOTE SITE sources dockerfile image image sources image with sources GitHub CircleCI AWS Docker Hub build build with run with run image with sources fire!

Slide 33

Slide 33 text

REMOTE SITE sources dockerfile image image with sources image with sources GitHub CircleCI AWS Docker Hub build image build image with sources run image with sources run image with sources fire!

Slide 34

Slide 34 text

SHOULD YOU TRY DOCKER?

Slide 35

Slide 35 text

REPOS https://github.com/sskorc/docker-silex https://github.com/sskorc/docker-symfony https://registry.hub.docker.com/u/sskorc/silex

Slide 36

Slide 36 text

THAT’S ALL, THANKS! @sskorc