feat(docker): docker compose で別バージョンタグをビルド可能にする#1405
Conversation
ec-cube サービスに build セクションを追加し、TAG を指定するだけで docker compose build から別 PHP バージョンのイメージをビルドできるようにした。 image と build を併記することで docker build + docker tag の 2 ステップが docker compose build に集約され、TAG 変更でイメージ名と build arg が同期する。 pull_policy: missing を明示し、通常の up ではレジストリから pull する 従来の挙動を維持。明示的に build したときのみローカルビルドを行う。 Co-Authored-By: Claude <noreply@anthropic.com>
📝 WalkthroughWalkthroughdocker-compose.ymlのec-cubeサービス構成にビルド機能を追加しました。pull_policyでイメージポーリング動作を制御し、buildブロックでローカルコンテキストおよびTAGパラメータを指定することで、TAGに応じた動的ビルドが可能になりました。 ChangesDocker Composeビルド設定
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docker-compose.yml`:
- Around line 17-19: The sample docker-compose commands in docker-compose.yml
lack the required COMPOSE_FILE environment variable to select the DB backend;
update those examples to show setting COMPOSE_FILE to include the base compose
file plus the DB-specific override (e.g.
COMPOSE_FILE=docker-compose.yml:docker-compose.mysql.yml or
COMPOSE_FILE=docker-compose.yml:docker-compose.postgres.yml) and then run the
same commands (build, build --no-cache, up -d --build) after that prefix so
users explicitly choose MySQL 8.4 or PostgreSQL 16 when using the examples.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| ## TAG=8.3-apache docker compose build | ||
| ## TAG=8.3-apache docker compose build --no-cache # キャッシュを使わず再ビルド | ||
| ## TAG=8.3-apache docker compose up -d --build # ビルドして起動 |
There was a problem hiding this comment.
運用コマンド例は COMPOSE_FILE 前提を明記してください。
Line 17-19 の例だと DB バックエンド切替の前提が抜けるため、ガイドライン運用とズレます。コメント例に COMPOSE_FILE を含めた方が安全です。
差分案
- ## TAG=8.3-apache docker compose build
- ## TAG=8.3-apache docker compose build --no-cache # キャッシュを使わず再ビルド
- ## TAG=8.3-apache docker compose up -d --build # ビルドして起動
+ ## COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml TAG=8.3-apache docker compose build
+ ## COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml TAG=8.3-apache docker compose build --no-cache # キャッシュを使わず再ビルド
+ ## COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml TAG=8.3-apache docker compose up -d --build # ビルドして起動As per coding guidelines, "docker-compose*.yml: Use Docker Compose with environment variables (COMPOSE_FILE) to set up the correct database backend (MySQL 8.4 or PostgreSQL 16)".
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ## TAG=8.3-apache docker compose build | |
| ## TAG=8.3-apache docker compose build --no-cache # キャッシュを使わず再ビルド | |
| ## TAG=8.3-apache docker compose up -d --build # ビルドして起動 | |
| ## COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml TAG=8.3-apache docker compose build | |
| ## COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml TAG=8.3-apache docker compose build --no-cache # キャッシュを使わず再ビルド | |
| ## COMPOSE_FILE=docker-compose.yml:docker-compose.${DB}.yml:docker-compose.dev.yml TAG=8.3-apache docker compose up -d --build # ビルドして起動 |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docker-compose.yml` around lines 17 - 19, The sample docker-compose commands
in docker-compose.yml lack the required COMPOSE_FILE environment variable to
select the DB backend; update those examples to show setting COMPOSE_FILE to
include the base compose file plus the DB-specific override (e.g.
COMPOSE_FILE=docker-compose.yml:docker-compose.mysql.yml or
COMPOSE_FILE=docker-compose.yml:docker-compose.postgres.yml) and then run the
same commands (build, build --no-cache, up -d --build) after that prefix so
users explicitly choose MySQL 8.4 or PostgreSQL 16 when using the examples.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1405 +/- ##
=======================================
Coverage 56.20% 56.20%
=======================================
Files 87 87
Lines 11090 11090
=======================================
Hits 6233 6233
Misses 4857 4857
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
docker-compose.ymlのec-cubeサービスにbuild:セクションを追加し、TAGを指定するだけでdocker compose buildから別 PHP バージョンのイメージをビルドできるようにしました。docker composeの枠外でdocker build+docker tagを手動実行していましたが、image:とbuild:を併記することでdocker compose buildの 1 コマンドに集約され、TAGを変更するだけでイメージ名と build arg (TAG) が同期します。pull_policy: missingを明示し、通常のupではこれまで通りレジストリ (ghcr.io) から pull する従来の挙動を維持しています。ローカルビルドは明示的にbuildを実行したときのみ行われます。Changes
ec-cubeサービスに以下を追加:pull_policy: missing— ローカルに無ければ build ではなく pull するbuild:セクション(context: .、args.TAG、pull: true)docker build/docker tag手順を案内するコメントを、新しいdocker compose buildベースの手順に更新。新しい運用
Test plan
検証環境: Docker Compose v5.1.4 / Docker Engine 29.4.3
docker compose config— 設定が妥当でpull_policy: missingが反映されるTAG=8.3-apache docker compose config—image:タグと build argTAGの両方に伝播TAG=8.2-apache docker compose up --dry-run— ローカル未取得時に build ではなく pull される(従来挙動を維持)TAG=8.2-apache docker compose build --dry-run— 明示 build 時に Building →ghcr.io/ec-cube/ec-cube2-php:8.2-apacheへ自動タグ付け🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート