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

AngularJSを通してDockerと触れ合った

 AngularJSを通してDockerと触れ合った

Angular meetup #3の資料です

Kenichiro Okada

November 22, 2015
Tweet

More Decks by Kenichiro Okada

Other Decks in Technology

Transcript

  1. AngularJSΛ௨ͯ͠ Dockerͱ৮Ε͋ͬͨ at Angular meetup #3

  2. • pastelInc • ͓࢓ࣄ͸PHP, JavaScript • ࠓ೔͸Χϝϥ୲౰

  3. DockerΛ஌Βͳ͍ͷʂʁ

  4. Docker͸ԿΛղܾ͢Δͷ͔

  5. σϓϩΠͷ໰୊ • σϓϩΠͨ͠Βಈ͔ͳ͔ͬͨ • σϓϩΠ؀ڥΛ͙͢༻ҙͰ͖ͳ͔ͬͨ • αʔό͝ͱʹҧ͏ϥΠϒϥϦɺόʔδϣϯ • ϓϩϏδϣχϯάͨ͘͠ͳ͍ •

    σϓϩΠ؀ڥ࠶ߏஙͰྦ
  6. ٻΊͨͷ͸ ΋ͬͱखܰͳσϓϩΠ؀ڥ

  7. Docker • ࠶ݱੑͷ͋ΔΠϯϑϥج൫Λਝ଎ʹߏங • “ίϯςφ”ಉ࢜͸ޓ͍ʹִ཭ • Φʔϓϯιʔε • DockerfileͰΠϯϑϥΛίʔυͱͯ͠هड़ •

    ΞϓϦͷݴޠʹدΒͣɺಉ͡΍ΓํͰσϓϩΠ
  8. VMͱίϯςφͷҧ͍

  9. Docker͸”ίϯςφ”Λѻ͏ ϓϥοτϑΥʔϜ

  10. AngularJSΞϓϦΛ࡞ͬͯ Docker্Ͱಈ͔ͯ͠ΈΑ͏ʂ

  11. • https://github.com/angular/material-start

  12. ΞϓϦέʔγϣϯಈ࡞؀ڥ • Node.js • 8080൪ϙʔτΛ࢖༻ $ node -v v0.12.5 $

    npm -v 2.11.3
  13. ίϯςφͷىಈ • docker run <Φϓγϣϯ> <Πϝʔδ໊:λά> <ίϚϯυ> <Ҿ਺> • -i

    ͸ίϯςφͰͷඪ४ೖྗΛՄೳʹ͢Δ • -t ͸ٖࣅλʔϛφϧΛల։͢Δ $ docker run -i -t node bash root@d7d20a8e7bb7:/# node -v v5.0.0 root@d7d20a8e7bb7:/# npm -v 3.3.6
  14. ίϯςφͷىಈ • docker run <Φϓγϣϯ> <Πϝʔδ໊:λά> <ίϚϯυ> <Ҿ਺> • -v

    ͸ϗετͷσΟϨΫτϦΛίϯςφʹϚ΢ϯτ͢Δ • -p ͸ϙʔτϑΥΞϦϯά͢Δ $ docker run -v `pwd`:/tmp -p 8080:8080 node ls -l total 60 drwxr-xr-x 2 root root 4096 Nov 10 00:43 bin drwxr-xr-x 2 root root 4096 Aug 26 16:31 boot drwxr-xr-x 5 root root 360 Nov 22 02:58 dev drwxr-xr-x 61 root root 4096 Nov 22 02:58 etc drwxr-xr-x 2 root root 4096 Aug 26 16:31 home drwxr-xr-x 12 root root 4096 Nov 10 00:43 lib
  15. ίϯςφͷఀࢭ • Ctrl + P + QͰίϯςφΛఀࢭͤͣʹ
 ݩͷλʔϛφϧʹ໭Δʢσλονʣ • ࠶౓Ξλον

    root@d7d20a8e7bb7:/# exit $ $ docker attach d7d20a8e7bb7 root@d7d20a8e7bb7:/#
  16. • ίϯςφΛىಈͯ͠ΞϓϦΛ࣮ߦ $ cd material-start $ docker run -it -v

    `pwd`:/tmp -p 8080:8080 node:0.12.5 bash root@d7d20a8e7bb7:/# node -v v0.12.5 root@d7d20a8e7bb7:/# npm -v 2.11.3 root@d7d20a8e7bb7:/# cd /tmp root@d7d20a8e7bb7:/tmp# npm start
  17. Dockerfile • Dockerίϯςφͷߏ੒Λ·ͱΊͯهड़ • docker buildͰΠϝʔδͷ࡞੒

  18. DockerΠϝʔδ • Πϝʔδ͸ϨΠϠͷॏ ͳΓ • ϨΠϠͱ͸docker run ͔ͯ͠ΒͷϑΝΠϧࠩ ෼ͷ͜ͱ

  19. • ΞϓϦ࣮ߦͷͨΊͷDockerfileΛ࡞੒ $ touch Dockerfile $ echo “FROM node:0.12.5-onbuild” >

    Dockerfile $ cat Dockerfile FROM node:0.12.5-onbuild
  20. Language Stack • Docker Hubʹ͸֤ݴޠͷެࣜϦϙδτϦ͕ଘ ࡏ͢Δ • λάʹΑΔόʔδϣϯͷࢦఆ͕Մೳ • ONBUILDσΟϨΫςΟϒΛؚΜͩΠϝʔδ͕

    ͋Δ
  21. FROM node:0.12.7 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app ONBUILD COPY

    package.json /usr/src/app/ ONBUILD RUN npm install ONBUILD COPY . /usr/src/app CMD [ "npm", "start" ]
  22. Πϝʔδ࡞੒ • docker build <Φϓγϣϯ> <PATH> • -t ͸Πϝʔδͷ<໊લ:λά>ΛܾΊΔ $

    docker build -t pastelinc/material-start .
  23. Πϝʔδදࣔ • docker images <Φϓγϣϯ> $ docker images REPOSITORY TAG

    IMAGE ID CREATED VIRTUAL SIZE pastelinc/material-start latest 820019b78a27 15 minutes ago 1.042 GB
  24. • DockerfileΛ࢖ͬͯΠϝʔδΛ࡞੒ • Πϝʔδ͔ΒίϯςφΛىಈ $ docker build -t pastelinc/material-start .

    $ docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE pastelinc/material-start latest 820019b78a27 15 minutes ago 1.042 GB $ docker run -d -p 3000:8080 pastelinc/material-start
  25. ·ͱΊ • Docker͸σϓϩΠͷ՝୊Λղܾͯ͘͠ΕΔ • DockerfileΛ༻ҙ͢Δͱ࣮ߦ؀ڥΛ͙͢ʹ࡞ΕΔ • ೰·ͣखܰʹΠϯϑϥ؀ڥΛͲ͜Ͱ΋ߏஙͰ͖ ָ͍ͯ͠ʂ • ݱࡏϓϩμΫγϣϯͰͷ࠾༻͸·ͩগͳ͍