Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Docker & PHP

Docker & PHP

Szymon Skórczyński

December 15, 2014
Tweet

More Decks by Szymon Skórczyński

Other Decks in Programming

Transcript

  1. TOP PROBLEMS Isolation from host OS and other environments Traceability

    of configuration changes Portability to share with colleagues and deploy easily
  2. 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
  3. 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
  4. THE ECOSYSTEM Image is like OVF or ISO Container is

    a running image Repository is a place to store images
  5. 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
  6. USAGE docker pull downloads an image docker run starts a

    container docker commit saves changes in an image docker push uploads an image
  7. 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
  8. 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"
  9. 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
  10. 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
  11. +

  12. REMOTE SITE sources dockerfile image image sources image GitHub CircleCI

    AWS Docker Hub build image build with run with run with fire!
  13. 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!
  14. 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!
  15. 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!