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
DockerのマルチプラットフォームイメージをGitHub Actionsでビルドして公開する...
Search
iwamot
PRO
September 25, 2024
Technology
4
540
DockerのマルチプラットフォームイメージをGitHub Actionsでビルドして公開する際に、参考にしたドキュメントと便利だったツール
2024-09-25
ENECHANGE I/O Day LT⼤会(社内イベント)
iwamot
PRO
September 25, 2024
Tweet
Share
More Decks by iwamot
See All by iwamot
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
690
名単体テスト 禁断の傀儡(モック)
iwamot
PRO
1
450
クォータ監視、AWS Organizations環境でも楽勝です✌️
iwamot
PRO
2
460
Cline、めっちゃ便利、お金が飛ぶ💸
iwamot
PRO
22
21k
開発組織を進化させる!AWSで実践するチームトポロジー
iwamot
PRO
3
1.2k
始めないともったいない!SLO運用で得られる3つのメリット
iwamot
PRO
1
140
あなたの人生も変わるかも?AWS認定2つで始まったウソみたいな話
iwamot
PRO
3
7.9k
効率的な技術組織が作れる!書籍『チームトポロジー』要点まとめ
iwamot
PRO
2
350
AWS⼊社という選択肢、⾒えていますか
iwamot
PRO
2
1.4k
Other Decks in Technology
See All in Technology
_第3回__AIxIoTビジネス共創ラボ紹介資料_20250617.pdf
iotcomjpadmin
0
150
地図も、未来も、オープンに。 〜OSGeo.JPとFOSS4Gのご紹介〜
wata909
0
110
Model Mondays S2E02: Model Context Protocol
nitya
0
220
登壇ネタの見つけ方 / How to find talk topics
pinkumohikan
3
360
強化されたAmazon Location Serviceによる新機能と開発者体験
dayjournal
2
200
データプラットフォーム技術におけるメダリオンアーキテクチャという考え方/DataPlatformWithMedallionArchitecture
smdmts
5
630
250627 関西Ruby会議08 前夜祭 RejectKaigi「DJ on Ruby Ver.0.1」
msykd
PRO
2
260
Clineを含めたAIエージェントを 大規模組織に導入し、投資対効果を考える / Introducing AI agents into your organization
i35_267
4
1.6k
【TiDB GAME DAY 2025】Shadowverse: Worlds Beyond にみる TiDB 活用術
cygames
0
1.1k
mrubyと micro-ROSが繋ぐロボットの世界
kishima
2
220
“社内”だけで完結していた私が、AWS Community Builder になるまで
nagisa53
1
380
ひとり情シスなCTOがLLMと始めるオペレーション最適化 / CTO's LLM-Powered Ops
yamitzky
0
420
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.7k
The Art of Programming - Codeland 2020
erikaheidi
54
13k
Building Flexible Design Systems
yeseniaperezcruz
328
39k
Building Adaptive Systems
keathley
43
2.6k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
790
The Cult of Friendly URLs
andyhume
79
6.5k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Unsuck your backbone
ammeep
671
58k
How STYLIGHT went responsive
nonsquared
100
5.6k
Navigating Team Friction
lara
187
15k
Transcript
Dockerのマルチプラットフォームイメージを GitHub Actionsでビルドして公開する際に、 参考にしたドキュメントと便利だったツール 2024-09-25 ENECHANGE I/O Day LT大会(社内イベント) VPoT兼CTO室マネージャー
岩本隆史
前置き 2/20
公開したもの:マルチプラットフォームイメージ2種 イメージ 追加ライブラリ(今はboto3のみ) ghcr.io/iwamot/collmbo:latest-slim 含まない ghcr.io/iwamot/collmbo:latest-full 含む iwamot/collmbo(社内でも使っているSlackbot OSS)の公式イメージ いずれも、linux/amd64とlinux/arm64をサポート
https://github.com/iwamot/collmbo/issues/6 でリクエストがあったため対応 3/20
レギュレーション:「無料の範囲内」 Docker Build Cloudを使う手もあるが、今回は無料にこだわった GitHub ActionsのArmランナーも今は有料なので回避 4/20
参考にしたドキュメント 5/20
Multi-platform image with GitHub Actions https://docs.docker.com/build/ci/github-actions/multi-platform/ Dockerが公開している、GitHub Actionsワークフローの実装例 6/20
3パターンの実装例が掲載 1. docker/build-push-actionで複数のプラットフォームを指定(直列的) 2. 各プラットフォームのビルドを複数ランナーで並列実行、その後マージ 3. 2と同じパターンでdocker/bake-actionを利用 今回は2を採用 1はビルド時間が長くなる 3はBakeの理解が必要
7/20
例を参考に「ビルド4並列・マージ2並列」で実装 matrix: platform: - linux/amd64 - linux/arm64 flavor: - name:
slim use_bedrock: false - name: full use_bedrock: true matrix: flavor: - slim - full https://github.com/iwamot/collmbo/blob/main/.github/workflows/publish.yml 8/20
Cache management with GitHub Actions https://docs.docker.com/build/ci/github-actions/cache/ Dockerが公開している、GitHub Actionsでのキャッシュ管理の実装例 9/20
5パターンの実装例が掲載 1. インラインキャッシュ(結果イメージのキャッシュのみエクスポート) 2. レジストリキャッシュ(中間レイヤーのキャッシュもエクスポート) 3. GitHubキャッシュ > キャッシュバックエンドAPI 4.
GitHubキャッシュ > キャッシュマウント 5. GitHubキャッシュ > ローカルキャッシュ 今回は2を採用 マルチステージビルドのため、中間レイヤーもキャッシュしたい ビルド間隔が長い(GitHubキャッシュは7日アクセスなしのエントリを削除) 10/20
docker/build-push-actionでtype=registryを指定 uses: docker/build-push-action@v6 with: platforms: ${{ matrix.platform }} build-args: |
USE_BEDROCK=${{ matrix.flavor.use_bedrock }} labels: ${{ steps.meta.outputs.labels }} outputs: type=image,name=${{ env.REGISTRY_IMAGE }},> push-by-digest=true,name-canonical=true,push=true cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ env.PLATFORM_PAIR }}-${{ matrix.flavor.name }} cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:cache-${{ env.PLATFORM_PAIR }}-${{ matrix.flavor.name }},mode=max 11/20
直近のビルドではキャッシュ利用率19%~25% https://github.com/iwamot/collmbo/actions/runs/10916311884 12/20
便利だったツール 13/20
Kesin11/actions-timeline:タイムライン可視化 https://github.com/Kesin11/actions-timeline 14/20
実行の結果、並列処理とキャッシュ活用で十分と判断 https://github.com/iwamot/collmbo-test/actions/runs/10576986797 15/20
suzuki-shunsuke/ghalint:セキュリティlinter https://github.com/suzuki-shunsuke/ghalint 16/20
初回実行時、2つのポリシー違反を検出 1. action_ref_should_be_full_length_commit_sha https://github.com/suzuki-shunsuke/ghalint/blob/main/docs/policies/008.md actions/checkout@v4 のようなバージョン指定は好ましくない いったん受容(GitHubとDockerのアクションのみ利用中。低リスクと判断) 2. job_timeout_minutes_is_required https://github.com/suzuki-shunsuke/ghalint/blob/main/docs/policies/012.md
ジョブにはタイムアウトを指定すべき(デフォルトでは6時間で強制終了) 対応済み 17/20
まとめ 18/20
成果:2種のイメージを公開するワークフローが完成 マルチプラットフォームイメージを無料かつ短時間でビルド、公開 セキュリティにも配慮(いったん受容したリスクは、余裕があれば解消したい) 19/20
参考にしたドキュメントと便利だったツール ドキュメント Multi-platform image with GitHub Actions:ワークフローの実装例 https://docs.docker.com/build/ci/github-actions/multi-platform/ Cache management
with GitHub Actions:キャッシュ管理の実装例 https://docs.docker.com/build/ci/github-actions/cache/ ツール Kesin11/actions-timeline:タイムライン可視化 https://github.com/Kesin11/actions-timeline suzuki-shunsuke/ghalint:セキュリティlinter https://github.com/suzuki-shunsuke/ghalint 20/20