feat: add image version tracking to DevContainer - #472
Conversation
- Add OCI image labels (version, source, title, description) - Write version to /etc/config-base-version during build - Pass IMAGE_VERSION build arg in GitHub Actions workflow - Add check-image-version.sh script for easy version checking - Update script/README.md with new script documentation This enables users to verify which version of config-base they are using by running `cat /etc/config-base-version` or `./script/check-image-version.sh` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe changes implement a Docker image versioning mechanism. They add version tracking to the Dockerfile via an ARG and OCI label, pass the semantic-release version through the GitHub Actions workflow build arguments, persist the version to a file within the image, and introduce a utility script to query and display the version information. Changes
Sequence Diagram(s)sequenceDiagram
participant Semantic as Semantic Release
participant GHA as GitHub Actions
participant Docker as Docker Build
participant Image as Built Image
participant Script as check-image-version.sh
Semantic->>GHA: Output release version
GHA->>Docker: Pass IMAGE_VERSION arg
Docker->>Image: Write version to /etc/config-base-version<br/>Set OCI labels
Image->>Script: Script executed in/against image
Script->>Image: Read /etc/config-base-version
Script->>Script: Output version & metadata
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 AI Code Review (Local Hook)Models: Codex (default) / Gemini (default) 🤖 Codex Review指摘事項なし(今回の差分に、正確性・性能・セキュリティ・保守性・開発者体験へ悪影響を与える変更由来の問題は見当たりませんでした)。 全体判定: patch is correct — 追加されたイメージバージョンの埋め込みと表示スクリプトは既存フローを壊さずに成立しており、明確な不整合やリグレッションは確認できません。信頼度 0.58 ✨ Gemini Reviewコードレビューを行いました。以下に発見事項を記載します。 発見事項
全体的な判定判定: patch is correct 理由: このパッチは、DevContainerイメージにバージョン情報を埋め込み、それを確認するための堅牢な仕組みを導入しています。Dockerfileのラベル付け、CIパイプラインでのバージョン引数の受け渡し、検証スクリプトの追加、そしてドキュメントの更新まで、一貫性のある変更が行われています。これにより、イメージのトレーサビリティと開発者体験が向上します。上記で指摘した点は、保守性をさらに高めるための提案であり、現在の変更の正確性を損なうものではありません。 信頼度: 0.95 🤖 Generated by post_pr_ai_review.py hook |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.devcontainer/Dockerfile:
- Around line 3-12: The LABEL block that references ARG IMAGE_VERSION should be
moved from its current position to the end of the Dockerfile (near the
version-file write step) so changes to IMAGE_VERSION only invalidate the final
image layer; locate the existing LABEL lines declaring
org.opencontainers.image.version, source, title, and description and cut them
out of their current position, then paste them after the version-file write step
(around the end of the file) so only the final metadata layer is rebuilt when
IMAGE_VERSION changes.
| # Build arguments | ||
| ARG CLAUDE_CODE_OAUTH_TOKEN | ||
| ARG ANTHROPIC_API_KEY | ||
| ARG IMAGE_VERSION="dev" | ||
|
|
||
| # OCI Image Labels for version tracking | ||
| LABEL org.opencontainers.image.version="${IMAGE_VERSION}" \ | ||
| org.opencontainers.image.source="https://github.com/keito4/config" \ | ||
| org.opencontainers.image.title="config-base" \ | ||
| org.opencontainers.image.description="DevContainer base image with Claude Code, Codex, and development tools" |
There was a problem hiding this comment.
Moving LABEL to the end of the Dockerfile would preserve layer caching.
The LABEL on line 9 references ${IMAGE_VERSION}, so every time the version changes, Docker invalidates this layer and all subsequent layers — forcing a full rebuild of the heavy apt-get, Node.js, Rust, npm install steps, etc. This negates registry cache benefits.
Move the LABEL block down next to the version-file write (around line 164) so that only the final layers are invalidated when the version changes.
Proposed fix
# Build arguments
ARG CLAUDE_CODE_OAUTH_TOKEN
ARG ANTHROPIC_API_KEY
ARG IMAGE_VERSION="dev"
-
-# OCI Image Labels for version tracking
-LABEL org.opencontainers.image.version="${IMAGE_VERSION}" \
- org.opencontainers.image.source="https://github.com/keito4/config" \
- org.opencontainers.image.title="config-base" \
- org.opencontainers.image.description="DevContainer base image with Claude Code, Codex, and development tools"Then near the end of the Dockerfile (after line 162):
# Write version file for easy version checking
RUN echo "${IMAGE_VERSION}" > /etc/config-base-version \
&& chmod 644 /etc/config-base-version
+
+# OCI Image Labels for version tracking (placed late to preserve layer cache)
+LABEL org.opencontainers.image.version="${IMAGE_VERSION}" \
+ org.opencontainers.image.source="https://github.com/keito4/config" \
+ org.opencontainers.image.title="config-base" \
+ org.opencontainers.image.description="DevContainer base image with Claude Code, Codex, and development tools"🤖 Prompt for AI Agents
In @.devcontainer/Dockerfile around lines 3 - 12, The LABEL block that
references ARG IMAGE_VERSION should be moved from its current position to the
end of the Dockerfile (near the version-file write step) so changes to
IMAGE_VERSION only invalidate the final image layer; locate the existing LABEL
lines declaring org.opencontainers.image.version, source, title, and description
and cut them out of their current position, then paste them after the
version-file write step (around the end of the file) so only the final metadata
layer is rebuilt when IMAGE_VERSION changes.
PR Review概要DevContainer イメージにバージョン情報を埋め込む機能の追加。OCI イメージラベルと /etc/config-base-version ファイルでバージョンを管理する実装です。 ✅ 良い点
🔍 改善提案1. デフォルト値の扱い(軽微)該当箇所: .devcontainer/Dockerfile:6 ARG IMAGE_VERSION="dev" のデフォルト値について、ローカルビルド時の意図を明示するコメントがあると良いです。 2. テストカバレッジ(中程度)Test plan にチェックリストがありますが、自動テストの追加を推奨します。
🔒 セキュリティ問題なし: バージョン情報の露出は一般的に安全で、セキュリティリスクは確認されません。 📊 パフォーマンス影響軽微: イメージサイズ増加 < 1KB、ビルド時間増加は無視できるレベル ✅ 総合評価承認推奨 - 軽微な改善提案はあるものの、実装は堅実で品質基準を満たしています。
保留中の CI チェックが完了したらマージ可能です。 🤖 Generated by Claude Code PR Review |
|
🎉 This PR is included in version 1.74.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Changes
Dockerfile
/etc/config-base-versionにバージョンを書き込みGitHub Actions Workflow
IMAGE_VERSIONbuild arg をビルド時に渡すよう修正check-image-version.sh
-vオプションで詳細情報を表示Usage
Test plan
docker buildでイメージをビルドしてラベルを確認/etc/config-base-versionの内容を確認check-image-version.shスクリプトの動作確認🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
New Features
Documentation