Skip to content

feat: add image version tracking to DevContainer - #472

Merged
keito4 merged 1 commit into
mainfrom
feat/add-image-version-label
Feb 12, 2026
Merged

feat: add image version tracking to DevContainer#472
keito4 merged 1 commit into
mainfrom
feat/add-image-version-label

Conversation

@keito4

@keito4 keito4 commented Feb 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • DevContainer イメージにバージョン情報を埋め込む機能を追加
  • ユーザーが使用中のイメージバージョンを簡単に確認可能に

Changes

  1. Dockerfile

    • OCI イメージラベルを追加(version, source, title, description)
    • /etc/config-base-version にバージョンを書き込み
  2. GitHub Actions Workflow

    • IMAGE_VERSION build arg をビルド時に渡すよう修正
  3. check-image-version.sh

    • バージョン確認用の新規スクリプト
    • -v オプションで詳細情報を表示

Usage

# DevContainer 内でバージョン確認
cat /etc/config-base-version

# または
./script/check-image-version.sh
./script/check-image-version.sh -v  # 詳細表示

Test plan

  • docker build でイメージをビルドしてラベルを確認
  • コンテナ内で /etc/config-base-version の内容を確認
  • check-image-version.sh スクリプトの動作確認

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Container images now include version tracking information
    • Added utility script to retrieve and display image version details with optional verbose output for additional metadata
  • Documentation

    • Updated documentation for the new version-checking utility

- 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>
@coderabbitai

coderabbitai Bot commented Feb 12, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Docker image versioning
.devcontainer/Dockerfile
Introduces IMAGE_VERSION ARG with default "dev", populates OCI image labels with version metadata, and writes version to /etc/config-base-version file in the final image.
CI/CD version propagation
.github/workflows/docker-image.yml
Adds IMAGE_VERSION=${{ steps.release.outputs.version }} build argument to pass semantic-release output version into Docker build process.
Version check utility
script/check-image-version.sh
New bash script that reads version from /etc/config-base-version, outputs version with optional verbose mode for additional metadata (source, releases URLs, current image info), and exits with status 1 if version file is missing.
Documentation
script/README.md
Documents the new check-image-version.sh script in Quick Reference and adds detailed usage section with version-tracking notes.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 A version hops into the image clear,
Released through workflows, labels appear,
The script checks deep in config's nest,
To show which version serves us best!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR: adding image version tracking functionality to the DevContainer. It's concise, specific, and directly reflects the primary changes across the Dockerfile, workflow, and new script.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-image-version-label

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4

keito4 commented Feb 12, 2026

Copy link
Copy Markdown
Owner Author

🔍 AI Code Review (Local Hook)

Models: Codex (default) / Gemini (default)

🤖 Codex Review

指摘事項なし(今回の差分に、正確性・性能・セキュリティ・保守性・開発者体験へ悪影響を与える変更由来の問題は見当たりませんでした)。

全体判定: patch is correct — 追加されたイメージバージョンの埋め込みと表示スクリプトは既存フローを壊さずに成立しており、明確な不整合やリグレッションは確認できません。信頼度 0.58

✨ Gemini Review

コードレビューを行いました。以下に発見事項を記載します。

発見事項

  1. 保守性: ハードコードされたURLの重複
    • ファイル: script/check-image-version.sh
    • 行範囲: 26-27
    • 説明: 詳細表示モードで使われるリポジトリのURL (https://github.com/keito4/config) がスクリプト内にハードコードされています。この情報は .devcontainer/Dockerfile 内のOCIラベル org.opencontainers.image.source と重複しています。保守性を向上させるために、docker inspect を用いてコンテナのラベルからこのURLを動的に読み込むことを検討してください。これにより、情報源がDockerfileに一元化され、将来リポジトリの場所が変更された際に修正箇所が1つになります。現在の実装でも機能しますが、これはDRY原則に従う良い機会です。

全体的な判定

判定: patch is correct

理由: このパッチは、DevContainerイメージにバージョン情報を埋め込み、それを確認するための堅牢な仕組みを導入しています。Dockerfileのラベル付け、CIパイプラインでのバージョン引数の受け渡し、検証スクリプトの追加、そしてドキュメントの更新まで、一貫性のある変更が行われています。これにより、イメージのトレーサビリティと開発者体験が向上します。上記で指摘した点は、保守性をさらに高めるための提案であり、現在の変更の正確性を損なうものではありません。

信頼度: 0.95


🤖 Generated by post_pr_ai_review.py hook

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .devcontainer/Dockerfile
Comment on lines +3 to +12
# 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

@claude

claude Bot commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

PR Review

概要

DevContainer イメージにバージョン情報を埋め込む機能の追加。OCI イメージラベルと /etc/config-base-version ファイルでバージョンを管理する実装です。


✅ 良い点

  1. OCI標準準拠: org.opencontainers.image.* ラベルを使用し、業界標準に従っている
  2. シンプルな設計: バージョンファイルとスクリプトの組み合わせで、複雑さを抑えている
  3. エラーハンドリング: check-image-version.sh でファイル不在時の適切なメッセージと終了コード
  4. ドキュメント更新: README に使用方法を明記
  5. 後方互換性考慮: 古いイメージでも動作し、適切なメッセージを表示

🔍 改善提案

1. デフォルト値の扱い(軽微)

該当箇所: .devcontainer/Dockerfile:6

ARG IMAGE_VERSION="dev" のデフォルト値について、ローカルビルド時の意図を明示するコメントがあると良いです。

2. テストカバレッジ(中程度)

Test plan にチェックリストがありますが、自動テストの追加を推奨します。

  • CI パイプライン内でビルドされたイメージの検証
  • /etc/config-base-version ファイルの存在とフォーマット確認
  • check-image-version.sh の動作確認(正常系/異常系)

🔒 セキュリティ

問題なし: バージョン情報の露出は一般的に安全で、セキュリティリスクは確認されません。


📊 パフォーマンス

影響軽微: イメージサイズ増加 < 1KB、ビルド時間増加は無視できるレベル


✅ 総合評価

承認推奨 - 軽微な改善提案はあるものの、実装は堅実で品質基準を満たしています。

  • ✅ コード品質: 良好
  • ✅ ベストプラクティス: 準拠
  • ✅ セキュリティ: 問題なし
  • ⚠️ テストカバレッジ: 自動テスト追加を推奨(必須ではない)
  • ✅ ドキュメント: 適切

保留中の CI チェックが完了したらマージ可能です。


🤖 Generated by Claude Code PR Review

@keito4
keito4 merged commit 6b85bb4 into main Feb 12, 2026
20 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.74.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@github-actions github-actions Bot added the released リリース済み label Feb 12, 2026
@keito4
keito4 deleted the feat/add-image-version-label branch March 1, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant