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

開発環境をDockerにしてみませんか? / #phpcon2017

開発環境をDockerにしてみませんか? / #phpcon2017

PHPカンファレンス2017の発表資料です

TAKAHASHI Kunihiko

October 08, 2017
Tweet

More Decks by TAKAHASHI Kunihiko

Other Decks in Technology

Transcript

  1. ͳΜ͍ͯ͏ͷ͸݁ߏເ෺ޠ ✓࢖༻͍ͯ͠Διϑτ΢ΣΞͷόʔδϣϯΞοϓͰಈ࡞͠ͳ͘ͳ ΓɺյΕΔ όʔδϣϯͷ૊Έ߹Θ͕ͤγϏΞ͗͢Δ  ✓7BHSBOU ✓7JSUVBM#PY ✓"OTJCMF ✓QSPWJTJPOίϚϯυΛ࣮ߦͯ͠΋ͳ͔ͥ͏·͍͔͘ͳ͍͜ͱ ͕͋Δ

    ✓ϑΝΠϧͷऔಘʹࣦഊ͢Δͱ͍ͬͨܰඍͳ΋ͷ͔Β΋ͬͱҙ ຯෆ໌ͳίέํͱ͔͍Ζ͍Ζ͋Δɾɾɾ ✓"OTJCMFͷϑΝΠϧͷϝϯςφϯε͕଺Δ ႈ౳ੑΛ୲อ͢Δ ͷ͸݁ߏΊΜͲ͍͘͞
  2. 7.ͱͷҧ͍ )8 04 Ծ૝Խ48 7JSUVBM#PY౳ )8 )8 04 04 "QBDIF

    3FEJT 1)1 "QQT )8 04 .Z42- 7. )8 04 %PDLFS&OHJOF "QBDIF 3FEJT 1)1 "QQT .Z42- %PDLFS
  3. %PDLFSͷಈ࡞ Registry image container docker pull docker push docker run

    docker commit Dockerfile docker build docker exec
  4. ࣮ࡍͲ͏࢖͏ͷ͔ʁ ✓JNBHFΛ४උ͢Δ 7BHSBOUͰݴ͏ͱCPYʹ͋ͨΔ  ✓CVJMEࡁΈͷJNBHFΛར༻͢Δ ✓ࣗ෼ͰJNBHFΛCVJME͢Δ ✓JNBHFΛ࣮ߦ SVO ͢ΔͱԾ૝؀ڥίϯςφͱͯ͠ಈ࡞ ͢Δ

    ✓7.ͱҧͬͯɺ࣮ߦΛऴྃ͢Δͱίϯςφʹର͢Δมߋ͸ഁ غ͞ΕΔ ✓࣮ߦ͢Δͨͼʹಉ͡ঢ়ଶ͔Βಈ࡞͢Δ ✓ͦΕͰ͸ࠔΔ৔߹ ·͊ɺ΄ͱΜͲ͕ͩ ɺϩʔΧϧͷϑΝ ΠϧγεςϜΛϚ΢ϯτͯͦ͜͠ʹσʔλΛӬଓԽ͢Δ
  5. EPDLFSίϚϯυ Registry image container docker pull docker push docker run

    docker commit Dockerfile docker build docker exec
  6. %PDLFSpMFͷྫ  FROM centos:7 MAINTAINER TAKAHASHI Kunihiko COPY ./php.ini /etc/php.ini

    RUN yum -y install epel-release \ && rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm \ && yum -y --enablerepo=remi,remi-php71 install httpd mod_ssl mysql-devel mysql-libs php php-cli php-mbstring php-mcrypt php-xml php-pdo php-mysqlnd php- opcache php-pecl-apcu \ && yum clean all \ && rm -rf /var/cache/yum/* EXPOSE 80 443 CMD /usr/sbin/httpd -DFOREGROUND
  7. %PDLFSpMFͷྫ  FROM php:7.1-apache MAINTAINER TAKAHASHI Kunihiko COPY ./php.ini /usr/local/etc/php/php.ini

    RUN apt-get update \ && apt-get install -y git g++ libmcrypt-dev libicu-dev libmcrypt4 libicu52 zlib1g-dev sqlite3 libsqlite3-dev \ && docker-php-ext-install mbstring mcrypt pdo pdo_sqlite intl zip \ && pecl install xdebug \ && docker-php-ext-enable xdebug \ && apt-get purge --auto-remove -y g++ libmcrypt-dev libicu-dev zlib1g-dev libsqlite3-dev \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \ && a2enmod rewrite \ && usermod -u 1000 www-data WORKDIR /var/www
  8. EPDLFSDPNQPTFZNMͷྫ version: '3.3' services: db: image: mysql:5.7 environment: - MYSQL_ROOT_PASSWORD=root

    volumes: - ./mysql/data:/var/lib/mysql:cached ports: - "3306:3306" web: build: . image: phpcon2017 volumes: - ../:/app:cached ports: - "8080:80" depends_on: - db