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
7k
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
970
Container Build Talk
orisano
3
2.4k
Better docker image+
orisano
6
5.9k
Socket.IO Introduction
orisano
0
3k
Profiling Go Application
orisano
11
7.7k
Multi-stage Builds Patterns & Practice
orisano
6
5k
better docker image
orisano
22
30k
the world of characters
orisano
8
1.4k
Other Decks in Programming
See All in Programming
テストコードのガイドライン 〜作成から運用まで〜
riku929hr
7
1.4k
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
570
ISUCON14感想戦で85万点まで頑張ってみた
ponyo877
1
600
ドメインイベント増えすぎ問題
h0r15h0
2
570
自動で //nolint を挿入する取り組み / Gopher's Gathering
utgwkk
1
100
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
190
知られざるDMMデータエンジニアの生態 〜かつてツチノコと呼ばれし者〜
takaha4k
1
470
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
300
QA環境で誰でも自由自在に現在時刻を操って検証できるようにした話
kalibora
1
140
PicoRubyと暮らす、シェアハウスハック
ryosk7
0
230
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
890
ErdMap: Thinking about a map for Rails applications
makicamel
1
690
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
570
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.3k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Embracing the Ebb and Flow
colly
84
4.5k
Documentation Writing (for coders)
carmenintech
67
4.5k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
39
1.9k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.2k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Optimising Largest Contentful Paint
csswizardry
33
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 -