Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
コンテナビルド最新事情 2022年度版 / Container Build 2022
Search
Kohei Ota
May 14, 2022
Technology
610
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コンテナビルド最新事情 2022年度版 / Container Build 2022
Kohei Ota
May 14, 2022
More Decks by Kohei Ota
See All by Kohei Ota
CloudNative Meets WebAssembly: Exploring Wasm's Potential to Replace Containers
inductor
4
3.7k
The Cloud Native Chronicles: 10 Years of Community Growth Inside and Outside Japan
inductor
0
210
Cracking the KubeCon CfP
inductor
2
950
KubeCon Recap -Platform migration at Scale-
inductor
1
1.1k
データベースとストレージのレプリケーション入門 / Intro-of-database-and-storage-replication
inductor
28
6.7k
KubeConのケーススタディから振り返る、Platform for Platforms のあり方と その実践 / Lessons from KubeCon case studies: Platform for Platforms and its practice
inductor
3
1.1k
オンラインの技術カンファレンスを安定稼働させるための取り組み / SRE activity for online conference platform
inductor
1
1.4k
Kubernetesネットワーキング初級者脱出ガイド / Kubernetes networking beginner's guide
inductor
23
8k
コンテナネイティブロードバランシングの話 / A story about container native load balancing
inductor
2
2.5k
Other Decks in Technology
See All in Technology
DGX Spark でどこまでハッキングができるのか?
kash1064
3
1.4k
専門領域のAIをどう評価するか
bengo4com
2
340
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
130
その Valkey 使いこなしていますか?
onk
PRO
5
1.6k
ウォンテッドリーの最近のプロダクトと技術の紹介
stomk
0
270
Metadata - Section 1: HTML Basics
mohab1
0
130
Benchmarking Disaggregated Serving on vLLM + Dynamo with a Real Coding-Agent Workload
nttcom
1
210
How to Design Configuration for Rails Applications
willnet
1
880
会社説明資料
persolserverworks
0
9.8k
Kiro Crewで「みのるん式」仕事術やってみた
minorun365
PRO
3
930
スキマバイトという雇用形態は存在しないので、雇用期間1日のアルバイト契約を事業者とワーカーが結ぶ手続きを支えるのがタイミーなんです
akitoshiga
0
210
Temporal 最高!でも改めて「日付」について調べたら人類の負債すぎる件
riyaamemiya
0
210
Featured
See All Featured
Navigating Team Friction
lara
192
16k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.4k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Exploring anti-patterns in Rails
aemeredith
4
540
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
67k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
We Have a Design System, Now What?
morganepeng
55
8.4k
We Are The Robots
honzajavorek
0
400
How to train your dragon (web standard)
notwaldorf
96
6.9k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Transcript
コンテナビルド最新事情 - 2022年度版- @_inductor_ 1
今日お話しすること • Dockerfileの新しい記法 ◦ mount=type ◦ Dockerfileのヒアドキュメント ◦ COPY --link
の話 • CIとビルドキャッシュの話
Dockerfileの新しい記法 • Dockerがサポートするビルドの新機能は「BuildKit」と呼ばれるOSSによって実装さ れている • BuildKitでは、より便利で賢くて高速なビルドを実現するためにいくつかの新機能を 継続的に追加(Dockerfileの書き方が変わる) ◦ 公式ドキュメントの通り ◦
Dockerfileの行頭に「# syntax=docker/dockerfile:1.4」を追加すると利用できる 例: RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ apt update && apt-get --no-install-recommends install -y gcc
Dockerfileの新しい記法 • Dockerがサポートするビルドの新機能は「BuildKit」と呼ばれるOSSによって実装さ れている • BuildKitでは、より便利で賢くて高速なビルドを実現するためにいくつかの新機能を 継続的に追加(Dockerfileの書き方が変わる) ◦ 公式ドキュメントの通り ◦
Dockerfileの行頭に「# syntax=docker/dockerfile:1.4」を追加すると利用できる 例: RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ apt update && apt-get --no-install-recommends install -y gcc ビルド中にだけ一時的に利用するが 作成されたイメージには不要な情報を ビルドツール内にキャッシュ
Dockerfileの新しい記法 • Dockerがサポートするビルドの新機能は「BuildKit」と呼ばれるOSSによって実装さ れている • BuildKitでは、より便利で賢くて高速なビルドを実現するためにいくつかの新機能を 継続的に追加(Dockerfileの書き方が変わる) ◦ 公式ドキュメントの通り ◦
Dockerfileの行頭に「# syntax=docker/dockerfile:1.4」を追加すると利用できる 例: RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ apt update && apt-get --no-install-recommends install -y gcc ビルド中にだけ一時的に利用するが 作成されたイメージには不要な情報を ビルドツール内にキャッシュ - mount typeの種類 - cache (ビルドキャッシュの保存領域) - GitHub Actions用のtype=ghaもある(便利) - secret/ssh (ビルド時に利用する秘密鍵)
Dockerfileの新しい記法 • Dockerがサポートするビルドの新機能は「BuildKit」と呼ばれるOSSによって実装さ れている • BuildKitでは、より便利で賢くて高速なビルドを実現するためにいくつかの新機能を 継続的に追加(Dockerfileの書き方が変わる) ◦ 公式ドキュメントの通り ◦
Dockerfileの行頭に「# syntax=docker/dockerfile:1.4」を追加すると利用できる 例: RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ apt update && apt-get --no-install-recommends install -y gcc ビルド中にだけ一時的に利用するが 作成されたイメージには不要な情報を ビルドツール内にキャッシュ - mount typeの種類 - cache (ビルドキャッシュの保存領域) - GitHub Actions用のtype=ghaもある(便利) - secret/ssh (ビルド時に利用する秘密鍵)
Dockerfileの新しい記法 • Dockerがサポートするビルドの新機能は「BuildKit」と呼ばれるOSSによって実装さ れている • BuildKitでは、より便利で賢くて高速なビルドを実現するためにいくつかの新機能を 継続的に追加(Dockerfileの書き方が変わる) ◦ 公式ドキュメントの通り ◦
Dockerfileの行頭に「# syntax=docker/dockerfile:1.4」を追加すると利用できる 例: RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ apt update && apt-get --no-install-recommends install -y gcc ビルド中にだけ一時的に利用するが 作成されたイメージには不要な情報を ビルドツール内にキャッシュ - mount typeの種類 - cache (ビルドキャッシュの保存領域) - GitHub Actions用のtype=ghaもある(便利) - secret/ssh (ビルド時に利用する秘密鍵) ヒアドキュメント記法も最近の アップデートで使えるようになった ビルド時にだけ必要なSSH鍵のマウント ビルドするときに $ docker build --ssh profile . でSSHの向き先を指定(CIの場合は実行開始時に秘密鍵を渡す)
COPYの新しいフラグ --link について • --linkを使うには「# syntax=docker/dockerfile:1.4」が必要 • 新しいキャッシュセマンティクス「--cache-from」を有効活用するための オプション ◦
マルチステージビルドを活用する際の中間ステージをCOPYで使えるようになる ので、COPY/ADDのコストが大幅に下がる ◦ これを使うと、前の行のビルドレイヤの変更有無にかかわらず、中間ステージの キャッシュが効くようになる
COPYの新しいフラグ --link について • --linkを使うには「# syntax=docker/dockerfile:1.4」が必要 • 新しいキャッシュセマンティクス「--cache-from(mount=type=cacheと組み合わせ使 うBuildKitのフラグ)」を有効活用するためのオプション ◦
マルチステージビルドを活用する際の中間ステージをCOPYで使えるようになる ので、COPY/ADDのコストが大幅に下がる ◦ これを使うと、前の行のビルドレイヤの変更有無にかかわらず、中間ステージの キャッシュが効くようになる これまでCIで効かせづらかった中間ステージの キャッシュが効くようになる!!! BuildKitで渡せるキャッシュのオプション
まとめ • BuildKitのオプションをうまく使えば、CIでのビルドを爆速にできる ◦ GitHub Actionsのインテグレーションが優秀すぎるが、CircleCIとか GitLab RunnerとかJenkinsとかでも同じ仕組みを作りこむことはできるはず • BuildKitで新しくサポートされたDockerfile記法をちょこっと追加するだけでキャッシュが
賢くなってビルドが爆速になる • BuildKitはいいぞ!!!!!!!!!!!!!!!! • 参考リンク: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md