Skip to content

feat(build): build/rebuild/up の再ビルド仕様を統一 (i07)#74

Merged
takemi-ohama merged 2 commits into
mainfrom
feat/separate-base-image-staleness
Jun 25, 2026
Merged

feat(build): build/rebuild/up の再ビルド仕様を統一 (i07)#74
takemi-ohama merged 2 commits into
mainfrom
feat/separate-base-image-staleness

Conversation

@takemi-ohama

Copy link
Copy Markdown
Contributor

概要

devbase build / devbase rebuild / devbase up の再ビルド機構が混乱していたため、キャッシュの扱いを 3 モードに整理し、rebuild / upbuild --expires に集約して仕様を統一しました(issues/i07.md)。

関連 Issue

  • issues/i07.md(仕様再考メモ + 実装プラン)

変更点

  • build の 3 モードに整理
    モード 子イメージ 親イメージ(FROM devbase-*
    devbase build キャッシュビルド(常に実行) 同左
    devbase build --no-cache 無条件 no-cache 無条件 no-cache
    devbase build --expires=n n日未満は再ビルドしない / n日以上は no-cache 親の作成日で独立判定
  • devbase rebuild = devbase build --expires=7 のシノニム化。従来の素の docker compose build --no-cache をやめ、devbase-base の 2 段ビルド + 期限判定(期限内はスキップ)に変更。
  • devbase up の自動準備を rebuild 相当に集約。共通リゾルバ _build_with_expires に一本化(「7 日未満は再ビルドしない」既存挙動は維持)。
  • devbase build--no-cache / --expires[=DAYS] を追加--expires は作成日判定が必要なため Python(project build)経路へ委譲。
  • container.py: _build_with_expires / _build_resolved / _resolve_dev_service を追加、cmd_rebuild / cmd_build / _ensure_images を更新。
  • cli.py: build parser に --no-cache / --expires を追加。
  • bin/devbase: top-level build --expires のルーティング追加。
  • docs(cli-reference.md)/ CHANGELOG / issues/i07.md を更新。
  • tests: _build_with_expires / _build_resolved のテスト追加、--base-cache 幻引数の否定アサーションを削除。

動作確認

  • uv run python -m pytest tests/ 全 827 件パス
  • bash -n bin/devbase(構文チェック)OK
  • build parser が --no-cache / --expires[=DAYS] を正しく解釈することを確認
  • 実コンテナでの devbase up / devbase rebuild / devbase build --expires の手動確認

補足

devbase upbuild: 定義サービスでイメージが期限内(既定 7 日未満)なら再ビルドせず既存イメージで起動し、期限切れのみ再ビルドします(rebuild = build --expires=7 と同一挙動)。

キャッシュの扱いを3モードに整理:
- devbase build           : キャッシュビルド (常に実行)
- devbase build --no-cache: 無条件で base/project とも no-cache
- devbase build --expires=n: n日未満は再ビルドせず、n日以上のみ no-cache
                             (親イメージ FROM devbase-* は作成日で独立判定)

devbase rebuild を build --expires=7 のシノニムに、devbase up の自動準備を
その rebuild 相当に集約。共通リゾルバ _build_with_expires に一本化した。

- container.py: _build_with_expires / _build_resolved / _resolve_dev_service を
  追加。cmd_rebuild は素の compose build --no-cache をやめ期限判定へ。cmd_build に
  --no-cache / --expires を追加。_ensure_images (up) を共通リゾルバへ委譲。
- cli.py: build parser に --no-cache / --expires[=DAYS] を追加。
- bin/devbase: build --expires は作成日判定のため Python(project build)へ委譲。
- docs/CHANGELOG/issues/i07.md: 3モード仕様を反映。
- tests: _build_with_expires/_build_resolved のテスト追加、--base-cache 幻引数の
  否定アサーションを削除。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 cross-review | round 1 | codex | COMMENT

修正提案はインラインコメントに記載しました。

Comment thread lib/devbase/cli.py Outdated

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 cross-review | round 1 | gemini | APPROVE

アーキテクチャの再設計(Pythonへの集約と3モード整理)が綺麗に行われており、テストも網羅的です。機能面は問題ありませんが、CLI の help テキストの追従漏れや引数バリデーションなど、主にユーザビリティ・堅牢性の観点でいくつか提案をインラインに残しました。

Comment thread lib/devbase/cli.py Outdated
Comment thread lib/devbase/cli.py Outdated
Comment thread lib/devbase/commands/container.py
Comment thread lib/devbase/commands/container.py Outdated
…排他化 ほか (PR#74)

- rebuild の add_parser help を実態 (build --expires=7 相当) に合わせて更新 (cli.py)
- --no-cache / --expires を add_mutually_exclusive_group で CLI レベル排他化し、
  併用時は usage error で落とす (silent no-cache を防止) (cli.py)
- 単体ビルド (image 指定) 時に --expires 併用を warn ログで通知 (container.py)
- Dockerfile FROM 抽出正規表現を小文字 from / --platform フラグ許容に堅牢化 (container.py)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@takemi-ohama

Copy link
Copy Markdown
Contributor Author

cross-review 最終スイープ (Step 7.5) 完了

最終 APPROVE ラウンドで残っていた open review thread 5 件をすべて対応・Resolve しました。未解決スレッドは 0 件 です。

対応内訳 (commit d941d90)

# 重要度 箇所 対応
1 major cli.py rebuild help rebuild の help/epilog を実態 build --expires=7 相当に更新 (fixed)
2 minor cli.py build --no-cache/--expires 併用の silent no-cache を排他化で解消 (fixed, #3 と同件)
3 minor cli.py:140 add_mutually_exclusive_group() で CLI レベル排他制御。併用は usage error (exit 2) (fixed)
4 minor container.py cmd_build 単体ビルド (image 指定) + --expires 併用時に warn ログ追加 (fixed)
5 minor container.py:1098 FROM 抽出正規表現を小文字 from / --platform 許容に堅牢化 (fixed)

サマリ

  • 対応 (fixed): 5 件 (major 1 / minor 4)
  • deferred: 0 / rejected: 0
  • 解消 thread: 5 件 / 残 open: 0 件
  • commit: d941d90 (feat/separate-base-image-staleness)
  • テスト: uv run pytest 全 827 件 pass

@takemi-ohama takemi-ohama merged commit eef8765 into main Jun 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant