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
640
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
AIエージェント・マイクロサービス時代。AWSでの手軽な構築法を考えて試してみた
iwamot
PRO
1
32
これがLambdaレス時代のChatOpsだ!実例で学ぶAmazon Q Developerカスタムアクション活用法
iwamot
PRO
9
1.4k
Developer Certificate of Origin、よさそう
iwamot
PRO
0
33
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた CODT 2025 クロージングイベント版
iwamot
PRO
1
110
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた
iwamot
PRO
3
92
IPA&AWSダブル全冠が明かす、人生を変えた勉強法のすべて
iwamot
PRO
14
11k
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
1.1k
名単体テスト 禁断の傀儡(モック)
iwamot
PRO
1
590
クォータ監視、AWS Organizations環境でも楽勝です✌️
iwamot
PRO
2
590
Other Decks in Technology
See All in Technology
AR Guitar: Expanding Guitar Performance from a Live House to Urban Space
ekito_station
0
270
戰略轉變:從建構 AI 代理人到發展可擴展的技能生態系統
appleboy
0
160
202512_AIoT.pdf
iotcomjpadmin
0
160
Claude Codeを使った情報整理術
knishioka
15
11k
人工知能のための哲学塾 ニューロフィロソフィ篇 第零夜 「ニューロフィロソフィとは何か?」
miyayou
0
130
Snowflake Industry Days 2025 Nowcast
takumimukaiyama
0
150
テストセンター受験、オンライン受験、どっちなんだい?
yama3133
0
190
BidiAgent と Nova 2 Sonic から考える音声 AI について
yama3133
2
130
20251203_AIxIoTビジネス共創ラボ_第4回勉強会_BP山崎.pdf
iotcomjpadmin
0
150
2025年のデザインシステムとAI 活用を振り返る
leveragestech
0
510
MariaDB Connector/C のcaching_sha2_passwordプラグインの仕様について
boro1234
0
1.1k
_第4回__AIxIoTビジネス共創ラボ紹介資料_20251203.pdf
iotcomjpadmin
0
150
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
36
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.3k
The Curse of the Amulet
leimatthew05
0
6.1k
We Are The Robots
honzajavorek
0
130
Test your architecture with Archunit
thirion
1
2.1k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
860
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
1
210
Evolving SEO for Evolving Search Engines
ryanjones
0
84
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.8k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
170
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
410
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