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
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
Good Enough Types: Heuristic Type Inference for Ruby
riseshia
1
210
ぼくがかんがえたさいきょうのあうとぷっと
yama3133
0
190
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
23k
AIが書いたコードを信じられない問題 〜レビュー負荷を下げるために変えたこと〜 / The AI Code Trust Gap: Reducing the Review Burden
bitkey
PRO
7
1.3k
Claude Code を安全に使おう勉強会 / Claude Code Security Basics
masahirokawahara
11
32k
2026年、知っておくべき最新 サーバレスTips10選/serverless-10-tips
slsops
13
5.2k
The Journey of Box Building
tagomoris
4
2.4k
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.3k
Revisiting [CLS] and Patch Token Interaction in Vision Transformers
yu4u
0
360
目的ファーストのハーネス設計 ~ハーネスの変更容易性を高めるための優先順位~
gotalab555
8
2.2k
[OpsJAWS 40]リリースしたら終わり、じゃなかった。セキュリティ空白期間をAWS Security Agentで埋める
sh_fk2
3
240
Hacobu Tech Deck
hacobu
PRO
0
110
Featured
See All Featured
Building an army of robots
kneath
306
46k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
510
A Modern Web Designer's Workflow
chriscoyier
698
190k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
エンジニアに許された特別な時間の終わり
watany
106
240k
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
How to Ace a Technical Interview
jacobian
281
24k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
61
43k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
The Spectacular Lies of Maps
axbom
PRO
1
700
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