$30 off During Our Annual Pro Sale. View Details »

drone.ioを使って docker build & push自動化

jsoizo
October 14, 2015

drone.ioを使って docker build & push自動化

Docker LT 20151014

jsoizo

October 14, 2015
Tweet

More Decks by jsoizo

Other Decks in Technology

Transcript

  1. drone.ioΛ࢖ͬͯ docker build & pushࣗಈԽ Oct. 14, 2015 / Docker

    LT @jsoizo
  2. whoami • ໊લ : @jsoizo / Jun Sakamoto • ݴޠ

    : JavaScriptͱScalaΛগʑ • ࢓ࣄ : ޿ࠂωοτϫʔΫͷ։ൃ • ഑৴αʔό౳Ͱ70୆΄Ͳͷίϯςφ͕ৗ࣌ىಈ on Prod • ॴଐ :
  3. ·͍ʹͪ Docker࢖ͬͯΔͱ…

  4. Πϝʔδͷ build & push ͔ͬͨΔ͍໰୊

  5. Πϝʔδͷ build & push ͔ͬͨΔ͍໰୊ 4DBMBίϯύΠϧ஗͍

  6. Πϝʔδͷ build & push ͔ͬͨΔ͍໰୊ 4DBMBίϯύΠϧ஗͍ ΄΅खಈ(*U'MPX

  7. Πϝʔδͷ build & push ͔ͬͨΔ͍໰୊ 4DBMBίϯύΠϧ஗͍ ΠϝʔδQVTIͷ౓ʹ ଠฏ༸ͷ޲͜͏ͱ௨৴ ΄΅खಈ(*U'MPX

  8. ͱ͍͏͜ͱͰ ࣗಈԽ

  9. None
  10. • goݴޠͰॻ͔ΕͨCI (ݱߦόʔδϣϯ͸0.3) • OSS൛ https://github.com/drone/drone • δϣϒຖʹDocker ίϯςφΛ্ཱ࣮ͪ͛ͯߦ •

    GitHub, GitLabͷhook • gitϦϙδτϦ௚Լͷyamlʹ࣮ߦ಺༰Λهड़ • irc, Slack, Hipchat౳΁ͷ௨஌(by Plugin)
  11. ಈ࡞ϑϩʔ ίϯςφ ᶄ webhook ᶆ docker run ᶅ read drone.yml

    ᶉ docker push ᶇ test ᶈ docker builld ᶃ git push
  12. ΍ͬͯΔ͜ͱ͸ ཁ͢Δʹ

  13. Docker in Docker

  14. ͪͳΈʹ ެࣜͷϓϥάΠϯ ΋͋ΔΑ

  15. None
  16. υΩϡϝϯτҰ੾ ͳ͍͚Ͳͳ!!!

  17. ͻΔ͕͑ͬͯ Docker in Docker

  18. ϑΝΠϧߏ੒ ※ Χοί಺ͷ਺஋͸લ߲ͷ࣮ߦॱ % tree -L 2 -a . ├──

    .drone.yml // ઃఆϑΝΠϧ ᶅ ├── Dockerfile // ͓ͳ͡ΈϏϧυઃఆ ᶈ ├── activator └── drone ├── build.sh // docker build ᶈ&ᶉ └── test.sh // ςετ࣮ߦ༻sh ᶇ
  19. drone.yml image: jsoizo/java:openjdk-8u66-jdk cache: - /root/.ivy2/cache script: - /bin/sh +x

    drone/test.sh - /bin/sh +x drone/build.sh notify: slack: webhook_url: 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxx' username: 'drone' channel: '@jsoizo' on_started: false on_success: true on_failure: true
  20. image: jsoizo/java:openjdk-8u66-jdk cache: - /root/.ivy2/cache script: - /bin/sh +x drone/test.sh

    - /bin/sh +x drone/build.sh notify: slack: webhook_url: 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxx' username: 'drone' channel: '@jsoizo' on_started: false on_success: true on_failure: true JNBHFίϯςφͷΠϝʔδ drone.yml
  21. image: jsoizo/java:openjdk-8u66-jdk cache: - /root/.ivy2/cache script: - /bin/sh +x drone/test.sh

    - /bin/sh +x drone/build.sh notify: slack: webhook_url: 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxx' username: 'drone' channel: '@jsoizo' on_started: false on_success: true on_failure: true drone.yml DBDIF࠶ར༻෺ΛΩϟογϡ
  22. image: jsoizo/java:openjdk-8u66-jdk cache: - /root/.ivy2/cache script: - /bin/sh -x drone/test.sh

    - /bin/sh -x drone/build.sh notify: slack: webhook_url: 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxx' username: 'drone' channel: '@jsoizo' on_started: false on_success: true on_failure: true TDSJQUࣗಈԽ͍ͨ͠ॲཧ drone.yml
  23. image: jsoizo/java:openjdk-8u66-jdk cache: - /root/.ivy2/cache script: - /bin/sh +x drone/test.sh

    - /bin/sh +x drone/build.sh notify: slack: webhook_url: 'https://hooks.slack.com/services/xxxxxxxxxxxxxxxxxx' username: 'drone' channel: '@jsoizo' on_started: false on_success: true on_failure: true OPUJGZ׬ྃ௨஌ઌ drone.yml
  24. test.sh #!/bin/bash -eu # ςετ࣮ߦ ./activator test

  25. build.sh #!/bin/bash -eu # DockerσʔϞϯىಈ /usr/local/bin/wrapdocker & sleep 5 DRONE_COMMIT_SHORT=`git

    rev-parse --short ${DRONE_COMMIT}` # quay.ioʹϩάΠϯ docker login -e="." -u="jsoizo+drone_20151014" -p="XXXXXXXXXXX" quay.io # build docker build -t quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-${DRONE_COMMIT_SHORT} . # push docker push quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-${DRONE_COMMIT_SHORT} # DockerσʔϞϯऴྃ start-stop-daemon --stop --pidfile "/var/run/docker.
  26. #!/bin/bash -eu # DockerσʔϞϯىಈ /usr/local/bin/wrapdocker & sleep 5 DRONE_COMMIT_SHORT=`git rev-parse

    --short ${DRONE_COMMIT}` # quay.ioʹϩάΠϯ docker login -e="." -u="jsoizo+drone_20151014" -p="XXXXXXXXXXX" quay.io # build docker build -t quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-${DRONE_COMMIT_SHORT} . # push docker push quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-${DRONE_COMMIT_SHORT} # DockerσʔϞϯऴྃ start-stop-daemon --stop --pidfile "/var/run/docker. build.sh MPHJO
  27. #!/bin/bash -eu # DockerσʔϞϯىಈ /usr/local/bin/wrapdocker & sleep 5 DRONE_COMMIT_SHORT=`git rev-parse

    --short ${DRONE_COMMIT}` # quay.ioʹϩάΠϯ docker login -e="." -u="jsoizo+drone_20151014" -p="XXXXXXXXXXX" quay.io # build docker build -t quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-$ {DRONE_COMMIT_SHORT} . # push docker push quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-${DRONE_COMMIT_SHORT} # DockerσʔϞϯऴྃ build.sh CVJME
  28. #!/bin/bash -eu # DockerσʔϞϯىಈ /usr/local/bin/wrapdocker & sleep 5 DRONE_COMMIT_SHORT=`git rev-parse

    --short ${DRONE_COMMIT}` # quay.ioʹϩάΠϯ docker login -e="." -u="jsoizo+drone_20151014" -p="XXXXXXXXXXX" quay.io # build docker build -t quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-${DRONE_COMMIT_SHORT} . # push docker push quay.io/jsoizo/play-docker-lt-20151014:${DRONE_BRANCH}-$ {DRONE_COMMIT_SHORT} # DockerσʔϞϯऴྃ build.sh QVTI
  29. ͪͳΈʹ

  30. Registry :

  31. • CoreOS͕ࣾӡӦ͢ΔDocker Registry • “͖ʔ͍͓͋ʔ”ͬͯಡΉͬΆ͍ʔ • DockerHubͱൺ΂ͯ • (࠾༻౰࣌͸) ΠϝʔδͷDL͕଎͔ͬͨ

    • [ࢲݟ] Web UIͷૢ࡞ੑ͕ྑ͍ • DockerHubΈͨ͘ token Ͱpushͱ͔ग़དྷͳ͍͕ • RobotΞΧ΢ϯτΛ࡞ΕΔ => ࣗಈԽͷ͓ڙʹ
  32. drone.ioࢼͯ͠Έͨ ݁ՌɺͲ͏Α???

  33. ͱΓ͋͑ͣ ࣗಈԽग़དྷͨ

  34. ͕ɺ՝୊͕ࢁ੝ΓͰ վળͷ༨஍͋Γ

  35. ͕ɺ՝୊͕ࢁ੝ΓͰ վળͷ༨஍͋Γ '30.ͷΠϝʔδΛ ຖճ%-ͯ͠Δ (JU'MPXΛ ࣗಈԽͰ͖ͯͳ͍ Ϗϧυ࣌ʹ%-ͨ͠KBSΛ Ωϟογϡ͍ͨ͠

  36. ҰํͰɺ ϙδςΟϒͳ࿩

  37. v0.4Ͱେ෯ʹ ػೳ௥Ճ͕͋Δ໛༷ https://github.com/drone/drone/tree/0.4.0 http://readme.drone.io/docs/build/index.html

  38. ྫ) ίϯςφىಈ࣌ͷ Φϓγϣϯ͕૿͑Δ WPMVNFΛࢦఆͰ͖Δ ˠϗετͷTPDLFUϚ΢ϯτ͢Ε͹ %PDLFSJO%PDLFS͔Βଔۀग़དྷͦ͏

  39. ྫ) docker-compose෩ʹ αϙʔτίϯςφΛ ্͛ΒΕΕΔ FH"FSPTQJLFͳͲͷ ϨΞͳ%#΁ͷࢀরͱ͔ʹ

  40. ·ͱΊ

  41. Summary • drone.io : golang੡ CI • drone.ymlʹॻ͔Εͨͱ͓ΓʹϏϧυͯ͘͠ΕΔ • drone.io؀ڥԼͰͷdockerͷΠϝʔδϏϧυ

    • Docker in Docker • plugin͸υΩϡϝϯτෆ଍ͰఘΊͨ • Service(link)Λ্ख͘࢖͏ํ๏͕͋Γͦ͏ • ·ͩग़དྷΔ͜ͱগͳ͍(v0.3)ͷͰԿͰ΋΍Γ͍ͨਓʹ͸ΩπΠ • v0.4Ͱվળ͞Εͦ͏
  42. Thank You!!!