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

Docker & PHP

Docker & PHP

Szymon Skórczyński

February 18, 2016
Tweet

More Decks by Szymon Skórczyński

Other Decks in Programming

Transcript

  1. 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 VM
  2. php: build: . links: [db] volumes: - .:/var/www/docker-symfony nginx: image:

    nginx:1.9.10 links: [php] volumes_from: [php] volumes: - ./docker/vhost.conf:/etc/nginx/conf.d/default.conf ports: ["80:80"] db: image: mongo:3.2.1 volumes: - /mnt/sda1/var/lib/mongo-data:/data/db ports: ["27017:27017"] docker-compose.yml
  3. FROM php:5.6.18-fpm RUN apt-get update \ && curl -sL https://deb.nodesource.com/setup

    | bash - \ && apt-get install -y git libssl-dev zlib1g-dev libicu-dev g++ \ && pecl install mongo \ && echo extension=mongo.so > /usr/local/etc/php/conf.d/mongo.ini \ && pecl install apcu-beta \ && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ && docker-php-ext-install zip mbstring intl RUN curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/bin/composer ADD docker/php.ini /usr/local/etc/php/php.ini WORKDIR /var/www/docker-symfony Dockerfile
  4. FROM php:5.6.18-fpm RUN apt-get update \ && curl -sL https://deb.nodesource.com/setup

    | bash - \ && apt-get install -y git libssl-dev zlib1g-dev libicu-dev g++ \ && pecl install mongo \ && echo extension=mongo.so > /usr/local/etc/php/conf.d/mongo.ini \ && pecl install apcu-beta \ && echo extension=apcu.so > /usr/local/etc/php/conf.d/apcu.ini \ && docker-php-ext-install zip mbstring intl RUN curl -sS https://getcomposer.org/installer | php \ && mv composer.phar /usr/bin/composer ADD docker/php.ini /usr/local/etc/php/php.ini WORKDIR /var/www/docker-symfony Dockerfile
  5. php: image: sskorc/docker-symfony-dist:latest links: [db] volumes: - /var/www/docker-symfony nginx: image:

    nginx:1.9.10 links: [php] volumes_from: [php] volumes: - /var/app/vhost.conf:/etc/nginx/conf.d/default.conf ports: ["80:80"] db: image: mongo:3.2.1 volumes: - /var/app/db:/data/db ports: ["27017:27017"] Stackfile
  6. FROM sskorc/symfony2-mongo:latest ADD docker/php.ini /usr/local/etc/php/php.ini ADD . /var/www/docker-symfony RUN cd

    /var/www/docker-symfony && composer install -n WORKDIR /var/www/docker-symfony Dockerfile
  7. checkout sources GitHub AWS EC2 node #1 Docker Hub build

    sf2 image AWS EC2 node #2 AWS EC2 node #n Tutum trigger deploy
  8. checkout sources GitHub AWS EC2 node #1 Docker Hub build

    sf2 image AWS EC2 node #2 AWS EC2 node #n Tutum trigger deploy Travis CI run tests pull other images push sf2 image pull images
  9. language: ruby services: [docker] before_install: - docker login -e="$D_EMAIL" -u="$D_USERNAME"

    -p="$D_PASSWORD" before_script: - rm web/app_dev.php web/config.php web/info.php script: - docker build -f Dockerfile.remote -t sskorc/docker-symfony-dist . - docker-compose --file=docker-compose-remote.yml up -d - docker exec -it dockersymfony_php_1 bash -c "bin/phing test" - docker exec -it dockersymfony_php_1 bash -c "bin/phing quality" deploy: provider: script script: ./deploy.sh skip_cleanup: true on: branch: master .travis.yml
  10. #! /bin/bash docker tag sskorc/docker-symfony-dist:latest sskorc/docker-symfony- dist:$TRAVIS_BUILD_NUMBER docker push sskorc/docker-symfony-dist

    curl -u sskorc:$TUTUM_API_KEY -H "Content-Type: application/json" -X POST -d '{"reuse_volumes":false}' https://dashboard.tutum.co/api/ v1/service/$PHP_SERVICE_UUID/redeploy/ deploy.sh