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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
iwamot
PRO
September 25, 2024
Technology
4
690
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
8万デプロイ
iwamot
PRO
2
270
AIエージェント・マイクロサービス時代。AWSでの手軽な構築法を考えて試してみた
iwamot
PRO
1
72
これがLambdaレス時代のChatOpsだ!実例で学ぶAmazon Q Developerカスタムアクション活用法
iwamot
PRO
10
2.1k
Developer Certificate of Origin、よさそう
iwamot
PRO
0
56
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた CODT 2025 クロージングイベント版
iwamot
PRO
1
150
復号できなくなると怖いので、AWS KMSキーの削除を「面倒」にしてみた
iwamot
PRO
3
120
IPA&AWSダブル全冠が明かす、人生を変えた勉強法のすべて
iwamot
PRO
14
12k
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
1.3k
名単体テスト 禁断の傀儡(モック)
iwamot
PRO
1
660
Other Decks in Technology
See All in Technology
脳が溶けた話 / Melted Brain
keisuke69
1
1k
Phase05_ClaudeCode入門
overflowinc
0
2.2k
Phase02_AI座学_応用
overflowinc
0
2.9k
FastMCP OAuth Proxy with Cognito
hironobuiga
3
210
Laravelで学ぶOAuthとOpenID Connectの基礎と実装
kyoshidaxx
4
1.9k
Embeddings : Symfony AI en pratique
lyrixx
0
290
OpenClawでPM業務を自動化
knishioka
1
130
Phase04_ターミナル基礎
overflowinc
0
2.4k
Why we keep our community?
kawaguti
PRO
0
260
「通るまでRe-run」から卒業!落ちないテストを書く勘所
asumikam
2
650
AIエージェント×GitHubで実現するQAナレッジの資産化と業務活用 / QA Knowledge as Assets with AI Agents & GitHub
tknw_hitsuji
0
230
夢の無限スパゲッティ製造機 #phperkaigi
o0h
PRO
0
370
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
500
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Rails Girls Zürich Keynote
gr2m
96
14k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
250
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
190
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
280
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
160
So, you think you're a good person
axbom
PRO
2
2k
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
93
Side Projects
sachag
455
43k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
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