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
700
4
Share
DockerのマルチプラットフォームイメージをGitHub Actionsでビルドして公開する際に、参考にしたドキュメントと便利だったツール
2024-09-25
ENECHANGE I/O Day LT⼤会(社内イベント)
iwamot
PRO
September 25, 2024
More Decks by iwamot
See All by iwamot
パワポ作るマンをMCP Apps化してみた
iwamot
PRO
0
350
8万デプロイ
iwamot
PRO
2
320
AIエージェント・マイクロサービス時代。AWSでの手軽な構築法を考えて試してみた
iwamot
PRO
1
77
これがLambdaレス時代のChatOpsだ!実例で学ぶAmazon Q Developerカスタムアクション活用法
iwamot
PRO
10
2.3k
Developer Certificate of Origin、よさそう
iwamot
PRO
0
61
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた CODT 2025 クロージングイベント版
iwamot
PRO
1
170
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた
iwamot
PRO
3
130
IPA&AWSダブル全冠が明かす、人生を変えた勉強法のすべて
iwamot
PRO
14
12k
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
1.3k
Other Decks in Technology
See All in Technology
エージェントスキルを作って自分のインプットに役立てよう
tsubakimoto_s
0
340
プラットフォームエンジニアリングの実践 - AWS コンテナサービスで構築する社内プラットフォーム / AWS Containers Platform Meetup #1
literalice
1
140
EarthCopilotに学ぶマルチエージェントオーケストレーション
nakasho
0
290
クラウドネイティブな開発 ~ 認知負荷に立ち向かうためのコンテナ活用
literalice
0
120
Introduction to Sansan Meishi Maker Development Engineer
sansan33
PRO
0
390
Data Hubグループ 紹介資料
sansan33
PRO
0
2.9k
国内外の生成AIセキュリティの最新動向 & AIガードレール製品「chakoshi」のご紹介 / Latest Trends in Generative AI Security (Domestic & International) & Introduction to AI Guardrail Product "chakoshi"
nttcom
2
340
No Types Needed, Just Callable Method Check
dak2
1
1.2k
[OAWTT26][THR1028] Oracle AI Database 26ai へのアップグレード:ベストプラクティスと最新情報
oracle4engineer
PRO
1
100
データを"持てない"環境でのアノテーション基盤設計
sansantech
PRO
1
110
ARIA Notifyについて
ryokatsuse
1
120
QGISプラグイン CMChangeDetector
naokimuroki
1
400
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
141
7.4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
130
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
230
The Art of Programming - Codeland 2020
erikaheidi
57
14k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
210
New Earth Scene 8
popppiees
3
2.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Believing is Seeing
oripsolob
1
110
Speed Design
sergeychernyshev
33
1.6k
For a Future-Friendly Web
brad_frost
183
10k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
150
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