Multi-stage Builds Patterns & Practice
by
orisano
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Multi-stage Builds Patterns & Practice Docker Meetup Tokyo #26 #dockertokyo @orisano
Slide 2
Slide 2 text
ࣗݾհ • @orisano • ۦ͚ग़͠ͷΞϓϦέʔγϣϯΤϯδχΞ • ޮతͳdocker buildΛࢦͯ͠ؤு͍ͬͯΔ
Slide 3
Slide 3 text
օ͞Μ Multi-stage Builds ͯ͠·͔͢ʁ
Slide 4
Slide 4 text
ͦͦ Multi-stage Builds ͱ
Slide 5
Slide 5 text
Docker 17.05 (2017-05-04) ͔Βೖͬͨػೳ
Slide 6
Slide 6 text
Docker 17.05 (2017-05-04) ͔Βೖͬͨػೳ
Slide 7
Slide 7 text
എܠ
Slide 8
Slide 8 text
ͦͦ push͢ΔΠϝʔδΛ খ͍ͨ͘͞͠
Slide 9
Slide 9 text
Multi-stage BuildsҎલ
Slide 10
Slide 10 text
build༻ͷDockerfileΛͬͯ buildͯ͠volume͔Β ՌΛऔΓग़͢
Slide 11
Slide 11 text
Ұ࿈ͷྲྀΕΛ shell scriptͰॻ͍͍ͯͨ $ ./build.sh
Slide 12
Slide 12 text
͜ΕΛDockerfileͷΈͰ ࣮ݱͰ͖ΔΑ͏ʹͳͬͨ
Slide 13
Slide 13 text
ෳͷFROM COPY —from ͰͷผΠϝʔδ͔Βͷίϐʔ
Slide 14
Slide 14 text
্ͷΑ͏ͳഎܠͰՃ͞Εͨ Multi-stage Builds
Slide 15
Slide 15 text
͑Δͷ͏ͷ͕ਓؒ
Slide 16
Slide 16 text
͍ΖΜͳ׆༻ํ๏͕͋Δ
Slide 17
Slide 17 text
https://medium.com/@tonistiigi/advanced- multi-stage-build-patterns-6f741b852fae
Slide 18
Slide 18 text
https://speakerdeck.com/ garethr/advanced-docker- image-build-patterns (2019-11-01 Velocity)
Slide 19
Slide 19 text
Multi-stage Builds Patterns
Slide 20
Slide 20 text
builder & app alias image tested app inner base image split step
Slide 21
Slide 21 text
builder & app alias image tested app inner base image split step
Slide 22
Slide 22 text
No content
Slide 23
Slide 23 text
#VJMEFS "QQ
Slide 24
Slide 24 text
builder & app alias image tested app inner base image split step
Slide 25
Slide 25 text
No content
Slide 26
Slide 26 text
base imageΛ ໌ࣔతʹڞ௨ԽͰ͖Δ
Slide 27
Slide 27 text
builder & app alias image tested app inner base image split step
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
#VJMEFS "QQ 5FTU
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
#VJMEFS "QQ 5FTU
Slide 32
Slide 32 text
builder & app alias image tested app inner base image split step
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
#BTF "QQ "QQ
Slide 35
Slide 35 text
builder & app alias image tested app inner base image split step
Slide 36
Slide 36 text
No content
Slide 37
Slide 37 text
'BU#VJMEFS "QQ
Slide 38
Slide 38 text
#VJMEFS "QQ 7FOEPS )FBWZ )FBWZ
Slide 39
Slide 39 text
cacheΛ࠷େݶ׆༻Ͱ͖Δ
Slide 40
Slide 40 text
Multi-stage Builds buildkitͱ૬ੑ͕ྑ͍
Slide 41
Slide 41 text
ฒྻbuildʹΑΔ ߴԽ͕ݟࠐΊΔʂ
Slide 42
Slide 42 text
Multi-stage builds࠷ߴʂ
Slide 43
Slide 43 text
͔͠͠
Slide 44
Slide 44 text
buildkit͡Όͳ͍ͱਏ͍
Slide 45
Slide 45 text
CIbuildkit ͑ͳ͔ͬͨΓ͢Δ
Slide 46
Slide 46 text
CI্ͷ Multi-stage Buildsͷ cacheઓུ
Slide 47
Slide 47 text
͜Ε·ͰͷΓํͩͱ খ͍͞ΠϝʔδͷcacheΛ ͯ͠͠·͏
Slide 48
Slide 48 text
ຊʹඞཁͳͷ ॏ͍Πϝʔδͷcache
Slide 49
Slide 49 text
CIʹ͓͚Δ Multi-stage Builds ΄΅ͯ͢ͷεςʔδΛ ໌ࣔతʹbuild͢Δ͔͠ͳ͍
Slide 50
Slide 50 text
ͦͷ্Ͱ Ͳ͏͍͏ઓུΛऔΔ͔
Slide 51
Slide 51 text
save & load Or push & pull + —cache-from
Slide 52
Slide 52 text
save & load ͷ߹
Slide 53
Slide 53 text
Pros ֎෦ʹstorage͕͋Ε ࣮ݱՄೳ ϑΝΠϧड͚͠ͷΈͰྑ͍
Slide 54
Slide 54 text
Cons αΠζ͕Ͱ͔͍ ಉ͡ϕʔεΠϝʔδͰॏෳ save͕ͳΜ͔ॏ͍
Slide 55
Slide 55 text
push & pull ͷ߹
Slide 56
Slide 56 text
Pros Registry͕͋ΕՄೳ ѹॖ͞Εͨঢ়ଶͰड͚͠ ϕʔεΠϝʔδ͕ॏෳ͠ͳ͍
Slide 57
Slide 57 text
Cons cache༻tag or image͕ඞཁ push & pullͷෛՙ
Slide 58
Slide 58 text
ͿͬͪΌ͚ݱঢ়Ͱ CI্ͷcache͕໘ष͗͢Δ
Slide 59
Slide 59 text
CIͰ cacheΛޮ͔͍ͤͨͳΒ 2 stage·Ͱ (ݸਓͷײͰ͢)
Slide 60
Slide 60 text
CIͱͷ૬ੑ͋Δ͕ pipeline͕ෳࡶʹͳͬͨΓ ࣮ͦͦݱͰ͖ͳ͔ͬͨΓ
Slide 61
Slide 61 text
Multi-stage Buildsͷ͍ॴ
Slide 62
Slide 62 text
buildΑΓpullͷ΄͏͕ଟ͍ dockerd͕มΘΒͳ͍ڥ खݩͰͷbuildޮΛ࠷େԽ
Slide 63
Slide 63 text
CI͖Ͱͳ͍
Slide 64
Slide 64 text
ͦΕͰΓ͍ͨਓͷͨΊʹ
Slide 65
Slide 65 text
࡞Γ·ͨ͠ orisano/castage
Slide 66
Slide 66 text
No content
Slide 67
Slide 67 text
DockerfileΛಡΜͰ͖ͯ ͯ͢ͷεςʔδΛநग़ pull ͱ cache-fromΛ ࣗಈੜͯ͘͠ΕΔ
Slide 68
Slide 68 text
No content
Slide 69
Slide 69 text
No content
Slide 70
Slide 70 text
͜Ε͚ͩͰղܾ͠ͳ͍
Slide 71
Slide 71 text
dockerdͱbuildkit —cache-from ͷڍಈ͕ҧ͏
Slide 72
Slide 72 text
ͳ͍߹ ແࢹͯ͘͠Εͨ΄͏͕خ͍͠
Slide 73
Slide 73 text
ॳظΠϝʔδ͕ͳ͍࣌ ͚ͩpipelineΛม͑Δͷਏ͍
Slide 74
Slide 74 text
݁
Slide 75
Slide 75 text
CIʹ͓͚Δ Multi-stage Builds͍͠