Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
dockerignore talk
Search
orisano
May 13, 2019
Programming
2
6.9k
dockerignore talk
orisano
May 13, 2019
Tweet
Share
More Decks by orisano
See All by orisano
OSS Performance Tuning Tips
orisano
8
5.6k
Docker-Compose & BuildKit
orisano
4
950
Container Build Talk
orisano
3
2.4k
Better docker image+
orisano
6
5.8k
Socket.IO Introduction
orisano
0
3k
Profiling Go Application
orisano
11
7.6k
Multi-stage Builds Patterns & Practice
orisano
6
5k
better docker image
orisano
22
30k
the world of characters
orisano
8
1.3k
Other Decks in Programming
See All in Programming
Arm移行タイムアタック
qnighy
0
310
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.3k
色々なIaCツールを実際に触って比較してみる
iriikeita
0
330
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
as(型アサーション)を書く前にできること
marokanatani
9
2.6k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
subpath importsで始めるモック生活
10tera
0
300
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.1k
Quine, Polyglot, 良いコード
qnighy
4
640
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
Fireside Chat
paigeccino
34
3k
The Cult of Friendly URLs
andyhume
78
6k
4 Signs Your Business is Dying
shpigford
180
21k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Transcript
dockerignoreͷ Container Build Meetup #2 #container_build @orisano
docker buildͷΛ͠·͢
%PDLFS$-* EPDLFSE
%PDLFS$-* EPDLFSE $ docker build .
%PDLFS$-* EPDLFSE $ docker build [build context]
%PDLFS$-* EPDLFSE $ docker build . 1. build contextΛtarͰarchive͢Δ
%PDLFS$-* EPDLFSE $ docker build . 2. dockerdʹରͯ͠POST͢Δ
%PDLFS$-* EPDLFSE $ docker build . 3. ड͚औͬͨtarΛల։
%PDLFS$-* EPDLFSE $ docker build . 4. DockerfileͷղऍΛ͢Δ
%PDLFS$-* EPDLFSE $ docker build . 5. εςʔδ͝ͱʹ࣮ߦ
%PDLFS$-* EPDLFSE $ docker build . 6. InstructionΛ࣮ߦ
%PDLFS$-* EPDLFSE $ docker build . 7. Instructionຖʹimage͕Ͱ͖Δ
%PDLFS$-* EPDLFSE $ docker build . 8.ऴΘͬͨΒ௨
ෆཁͳϑΝΠϧ build contextʹؚΊͨ͘ͳ͍
ͳͥʁ
1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ
1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ
େྔͷϑΝΠϧΛ ΞʔΧΠϒ͢Δͷॏ͍ (node_modulesͳͲ)
ΫϥΠΞϯτଆͰߦ͏͕ ݱঢ়̎ͭͷ࣮͕͋Δ
docker/cli (Go) docker/docker-py (Python)
docker/cli (Go) dockerίϚϯυ
docker/docker-py (Python)
Docker Engine APIΛ Python͔Β͏ͨΊͷͷ docker/compose ͕͍ͬͯΔ ͳΜ͔͍
AntiVirusͳͲ͕ I/OΛhook͍ͯ͠Δ߹ I/Oίετ͕͍
1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ
େ͖ͳϑΝΠϧΛૹΔͷ େม
1. Archiveͷίετ 2. సૹͷίετ 3. cacheͷͨΊ
COPYͰ ҙਤͯ͠ͳ͍ϑΝΠϧ͕ ରʹͳ͍ͬͯΔͱ cache͕յΕͯ࠷ѱ
build contextʹ ؚΊ͍͚ͯͳ͍ϑΝΠϧ ͕͋Δ
1. ೝূใ 2. ΞʔΩςΫνϟґଘ
1. ೝূใ 2. ΞʔΩςΫνϟґଘ
ݴΘ͕ͣͳ .envͳͲ
.git͕ةݥͳ߹͋Δ personal tokenͰͷ git cloneΛ͍ͯ͠ΔͳͲ
1. ೝূใ 2. ΞʔΩςΫνϟґଘ
package managerʹΑΔ͕ ͦͷڥ͚ͷbuildࡁΈ όΠφϦ͕͓͍ͯ͋Δ͜ͱ͕ (npm)
Ҏ্ͷΛղܾ͢ΔͨΊʹ dockerignore Λ͏
dockerignore
ޙΖʹॻ͍ͯ͋Δ pattern͕༏ઌ͞ΕΔ ઌ಄ʹ!Λ͚ͭΔͱ൱ఆͰ͖Δ
͑Δදه foo/* foo/** foo/?
෦Ͱ ਖ਼نදݱʹม͍ͯ͠Δ
ਖ਼نදݱͳΒΘ͔Δ ͱ͍͏ਓ͚ʹ github.com/orisano/dire
ରԠ͢Δਖ਼نදݱΛग़ྗ
Ͳ͏࣮ͬͯݱ͍ͯ͠Δ͔
%PDLFS$-* EPDLFSE $ docker build . 1. build contextΛtarͰarchive͢Δ
%PDLFS$-* EPDLFSE $ docker build . 0. build contextͷҎԼͷϑΝΠϧ͕readՄೳ͔֬ೝ (͜͜dockerignoreΛߟྀ͞ΕΔ)
%PDLFS$-* EPDLFSE $ docker build . 0.5. directoryΛtraverse͠ͳ͕Βdockerignoreʹ Ϛον͠ͳ͍ϑΝΠϧΛtarʹՃ͍ͯ͘͠
%PDLFS$-* EPDLFSE $ docker build . 1. build contextΛtarͰarchive͢Δ
༨ஊ
%PDLFS$-* EPDLFSE $ docker build . 0. build contextͷҎԼͷϑΝΠϧ͕readՄೳ͔֬ೝ (͜͜dockerignoreΛߟྀ͞ΕΔ)
ϑΝΠϧdockerignore͕ ίϯύΠϧ͞ΕΔΑ͏ʹ ͳ͍ͬͯͨ
docker/cli/pull/1577 Ͱमਖ਼͞Ε Docker 19.03 ͔ΒೖΓ·͢
ͪΐͬͱಛघͳྫ
monorepoͰ subsystemؒͷґଘ͕͋Δ ߹
େຊΛbuild contextʹ ͠ͳ͍ͱ͍͚ͳ͘ͳΔ
build context͕Ͱ͔͘ͳΔ
dockerignoreͰղܾ! ͢Δ͜ͱͰ͖ͳ͍
dockerignorebuildຖʹ ϑΝΠϧΛࢦఆͰ͖ͳ͍
subsystemຖʹ dockerignoreΛ࡞Γ buildͷͨͼʹ dockerignoreΛࣗಈੜ͢Δ Ξϓϩʔν͕༗ޮ
github.com/orisano/dignore
Α͋͘Δ
gitignoreͱdockerignore ͕ ΄΅ҰॹʹͳΔ
ͦ͏͍͏߹ʹ dockerignore ͍Βͳ͘ͳΔํ๏͕͋Δ
git archiveͬͯ ίϚϯυͬͨ͜ͱ͋Γ·͔͢
repositoryΛtarʹͰ͖Δ ίϚϯυ
tarʹ͢ΕbuildͰ͖ΔͷͰ
git archive HEAD | docker build -