dockerignore talk

dockerignore talk

6247c099ad62bf727a4f9df10b6c6f23?s=128

orisano

May 13, 2019
Tweet

Transcript

  1. dockerignoreͷ࿩ Container Build Meetup #2 #container_build @orisano

  2. docker buildͷ࿩Λ͠·͢

  3. %PDLFS$-* EPDLFSE

  4. %PDLFS$-* EPDLFSE $ docker build .

  5. %PDLFS$-* EPDLFSE $ docker build [build context]

  6. %PDLFS$-* EPDLFSE $ docker build . 1. build contextΛtarͰarchive͢Δ

  7. %PDLFS$-* EPDLFSE $ docker build . 2. dockerdʹରͯ͠POST͢Δ

  8. %PDLFS$-* EPDLFSE $ docker build . 3. ड͚औͬͨtarΛల։

  9. %PDLFS$-* EPDLFSE $ docker build . 4. DockerfileͷղऍΛ͢Δ

  10. %PDLFS$-* EPDLFSE $ docker build . 5. εςʔδ͝ͱʹ࣮ߦ

  11. %PDLFS$-* EPDLFSE $ docker build . 6. InstructionΛ࣮ߦ

  12. %PDLFS$-* EPDLFSE $ docker build . 7. Instructionຖʹimage͕Ͱ͖Δ

  13. %PDLFS$-* EPDLFSE $ docker build . 8.ऴΘͬͨΒ௨஌

  14. ෆཁͳϑΝΠϧ͸ build contextʹؚΊͨ͘ͳ͍

  15. ͳͥʁ

  16. 1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ

  17. 1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ

  18. େྔͷϑΝΠϧΛ ΞʔΧΠϒ͢Δͷ͸ॏ͍ (node_modulesͳͲ)

  19. ΫϥΠΞϯτଆͰߦ͏͕ ݱঢ়̎ͭͷ࣮૷͕͋Δ

  20. docker/cli (Go) docker/docker-py (Python)

  21. docker/cli (Go) dockerίϚϯυ

  22. docker/docker-py (Python)

  23. Docker Engine APIΛ Python͔Β࢖͏ͨΊͷ΋ͷ docker/compose ͕࢖͍ͬͯΔ ͳΜ͔஗͍

  24. AntiVirusͳͲ͕ I/OΛhook͍ͯ͠Δ৔߹ I/Oίετ͕΍͹͍

  25. 1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ

  26. େ͖ͳϑΝΠϧΛૹΔͷ͸ େม

  27. 1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ

  28. COPYͰ ҙਤͯ͠ͳ͍ϑΝΠϧ͕ ର৅ʹͳ͍ͬͯΔͱ cache͕յΕͯ࠷ѱ

  29. build contextʹ ؚΊͯ͸͍͚ͳ͍ϑΝΠϧ ͕͋Δ

  30. 1. ೝূ৘ใ 2. ΞʔΩςΫνϟґଘ

  31. 1. ೝূ৘ใ 2. ΞʔΩςΫνϟґଘ

  32. ݴΘͣ΋͕ͳ .envͳͲ

  33. .git͕ةݥͳ৔߹΋͋Δ personal tokenͰͷ git cloneΛ͍ͯ͠ΔͳͲ

  34. 1. ೝূ৘ใ 2. ΞʔΩςΫνϟґଘ

  35. package managerʹΑΔ͕ ͦͷ؀ڥ޲͚ͷbuildࡁΈ όΠφϦ͕͓͍ͯ͋Δ͜ͱ͕ (npm)

  36. Ҏ্ͷ໰୊Λղܾ͢ΔͨΊʹ dockerignore Λ࢖͏

  37. dockerignore

  38. ޙΖʹॻ͍ͯ͋Δ pattern͕༏ઌ͞ΕΔ ઌ಄ʹ!Λ͚ͭΔͱ൱ఆͰ͖Δ

  39. ࢖͑Δදه foo/* foo/** foo/?

  40. ಺෦Ͱ ਖ਼نදݱʹม׵͍ͯ͠Δ

  41. ਖ਼نදݱͳΒΘ͔Δ ͱ͍͏ਓ޲͚ʹ github.com/orisano/dire

  42. ରԠ͢Δਖ਼نදݱΛग़ྗ

  43. Ͳ͏΍࣮ͬͯݱ͍ͯ͠Δ͔

  44. %PDLFS$-* EPDLFSE $ docker build . 1. build contextΛtarͰarchive͢Δ

  45. %PDLFS$-* EPDLFSE $ docker build . 0. build contextͷҎԼͷϑΝΠϧ͕readՄೳ͔֬ೝ (͜͜΋dockerignoreΛߟྀ͞ΕΔ)

  46. %PDLFS$-* EPDLFSE $ docker build . 0.5. directoryΛtraverse͠ͳ͕Βdockerignoreʹ Ϛον͠ͳ͍ϑΝΠϧΛtarʹ௥Ճ͍ͯ͘͠

  47. %PDLFS$-* EPDLFSE $ docker build . 1. build contextΛtarͰarchive͢Δ

  48. ༨ஊ

  49. %PDLFS$-* EPDLFSE $ docker build . 0. build contextͷҎԼͷϑΝΠϧ͕readՄೳ͔֬ೝ (͜͜΋dockerignoreΛߟྀ͞ΕΔ)

  50. ϑΝΠϧ਺෼dockerignore͕ ίϯύΠϧ͞ΕΔΑ͏ʹ ͳ͍ͬͯͨ

  51. docker/cli/pull/1577 Ͱमਖ਼͞Ε Docker 19.03 ͔ΒೖΓ·͢

  52. ͪΐͬͱಛघͳྫ

  53. monorepoͰ subsystemؒͷґଘ͕͋Δ ৔߹

  54. େຊΛbuild contextʹ ͠ͳ͍ͱ͍͚ͳ͘ͳΔ

  55. build context͕Ͱ͔͘ͳΔ

  56. dockerignoreͰղܾ! ͢Δ͜ͱ͸Ͱ͖ͳ͍

  57. dockerignore͸buildຖʹ ϑΝΠϧΛࢦఆͰ͖ͳ͍

  58. subsystemຖʹ dockerignoreΛ࡞Γ buildͷͨͼʹ dockerignoreΛࣗಈੜ੒͢Δ Ξϓϩʔν͕༗ޮ

  59. github.com/orisano/dignore

  60. Α͋͘Δ࿩

  61. gitignoreͱdockerignore ͕ ΄΅ҰॹʹͳΔ

  62. ͦ͏͍͏৔߹ʹ͸ dockerignore ͍Βͳ͘ͳΔํ๏͕͋Δ

  63. git archiveͬͯ ίϚϯυ࢖ͬͨ͜ͱ͋Γ·͔͢

  64. repositoryΛtarʹͰ͖Δ ίϚϯυ

  65. tarʹ͢Ε͹buildͰ͖ΔͷͰ

  66. git archive HEAD | docker build -