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

    View full-size slide

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

    View full-size slide

  3. DockerΛ஌Βͳ͍ͷʂʁ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  6. ٻΊͨͷ͸
    ΋ͬͱखܰͳσϓϩΠ؀ڥ

    View full-size slide

  7. Docker
    • ࠶ݱੑͷ͋ΔΠϯϑϥج൫Λਝ଎ʹߏங
    • “ίϯςφ”ಉ࢜͸ޓ͍ʹִ཭
    • Φʔϓϯιʔε
    • DockerfileͰΠϯϑϥΛίʔυͱͯ͠هड़
    • ΞϓϦͷݴޠʹدΒͣɺಉ͡΍ΓํͰσϓϩΠ

    View full-size slide

  8. VMͱίϯςφͷҧ͍

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  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

    View full-size slide

  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

    View full-size slide

  15. ίϯςφͷఀࢭ
    • Ctrl + P + QͰίϯςφΛఀࢭͤͣʹ

    ݩͷλʔϛφϧʹ໭Δʢσλονʣ
    • ࠶౓Ξλον
    root@d7d20a8e7bb7:/# exit
    $
    $ docker attach d7d20a8e7bb7
    root@d7d20a8e7bb7:/#

    View full-size slide

  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

    View full-size slide

  17. Dockerfile
    • Dockerίϯςφͷߏ੒Λ·ͱΊͯهड़
    • docker buildͰΠϝʔδͷ࡞੒

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  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" ]

    View full-size slide

  22. Πϝʔδ࡞੒
    • docker build <Φϓγϣϯ>
    • -t ͸Πϝʔδͷ<໊લ:λά>ΛܾΊΔ
    $ docker build -t pastelinc/material-start .

    View full-size slide

  23. Πϝʔδදࣔ
    • docker images <Φϓγϣϯ>
    $ docker images
    REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
    pastelinc/material-start latest 820019b78a27 15 minutes ago 1.042 GB

    View full-size slide

  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

    View full-size slide

  25. ·ͱΊ
    • Docker͸σϓϩΠͷ՝୊Λղܾͯ͘͠ΕΔ
    • DockerfileΛ༻ҙ͢Δͱ࣮ߦ؀ڥΛ͙͢ʹ࡞ΕΔ
    • ೰·ͣखܰʹΠϯϑϥ؀ڥΛͲ͜Ͱ΋ߏஙͰ͖
    ָ͍ͯ͠ʂ
    • ݱࡏϓϩμΫγϣϯͰͷ࠾༻͸·ͩগͳ͍

    View full-size slide