issue109: 必須の環境変数が全 docker compose コマンドで必要な点を明記し .env による指定を案内する - #110
Draft
tichi73 wants to merge 5 commits into
Draft
issue109: 必須の環境変数が全 docker compose コマンドで必要な点を明記し .env による指定を案内する#110tichi73 wants to merge 5 commits into
tichi73 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #109 by clarifying that required environment variables in certain Docker Compose configurations are evaluated at compose-file load time, so they are needed for all docker compose subcommands (e.g., pull, config, down), and by recommending .env files as the primary way to provide them.
Changes:
- Add a new “環境変数の指定方法” section to
Environment.md, documenting required variables and.envbehavior/pitfalls. - Update
single/extdbandextra/jobmngrdREADMEs to introduce.envsetup beforedocker compose pull, and move per-command env examples into a “参考” section. - Relax
cluster/swarmby removing compose-levelDATABASE_URLrequired checks and relying onsetup_stack.shvalidation; also ignore.envfiles via.gitignore.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ke2/single/extdb/README.md |
Reorders setup to create .env first; explains “all subcommands need env” and adds a non-.env reference section. |
ke2/single/extdb/docker-compose.override.yml |
Improves required-var message for DATABASE_URL and documents why it affects all compose commands. |
ke2/extra/jobmngrd/README.md |
Reorders setup to create .env first; adds guidance and a non-.env reference section for AMQP_URL. |
ke2/extra/jobmngrd/docker-compose.override.yml |
Improves required-var message for AMQP_URL and documents load-time interpolation behavior. |
ke2/cluster/swarm/docker-compose.override.yml |
Removes compose-level DATABASE_URL requirement and adds rationale comments. |
Environment.md |
Adds consolidated documentation for required env vars and recommended .env usage, including parsing/escaping caveats. |
ChangeLog |
Records the documentation change and the swarm requirement relaxation for #109. |
.gitignore |
Ignores .env and .env.bak.* repository-wide to prevent accidental secret commits. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
ke2/single/extdb/README.md:128
- カスタマイズ例のコマンドが
DATABASE_URLの指定を含まないため、このセクションだけを参照して実行すると必須変数未指定でエラーになります(.envに設定済みである前提が明示されていません)。
この構成では、外部データベースへの接続情報として `DATABASE_URL` の指定が **必須** です(未指定の場合は `pull` を含むすべての docker compose コマンドがエラー停止します)。その他の環境変数は各構成で共通のため、[Environment.md](../../../Environment.md) を参照してください。カスタマイズした環境変数も `.env` に記述しておくことができます。
カスタマイズ例:
$ AMQP_PASSWORD='strong-pw' KOMPIRA_LOG_DIR=/var/log/kompira docker compose up -d
本構成では setup_stack.sh が DATABASE_URL の要否判定 (未指定なら DATABASE_HOST から既定値を組み立て、いずれも無ければエラー停止) を行なった上で docker-swarm.yml を生成するため、compose ファイル側の必須化は重複しており、README の環境変数表の 記述 (未指定時は DATABASE_HOST から構築) とも矛盾していた。また docker stack deploy には用いない docker compose pull まで停止させていた。
README を読まずにコマンドを実行した場合、このメッセージが唯一の導線になる ため、値の例だけでなく (1) up 以外のコマンドでも必要であること (2) .env に 書けば以後の指定が不要になること (3) Environment.md への誘導を含める。
- 必須の環境変数 (DATABASE_URL / AMQP_URL) が pull を含む全 docker compose コマンドで必要である点の明記、.env による指定方法の案内、エラーメッセージ の改善について追記 - cluster/swarm の DATABASE_URL 必須化を取り止めた件について追記
tichi73
force-pushed
the
feature/issue109-compose-env-docs
branch
from
July 29, 2026 02:35
bc719f6 to
820ca41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #109
背景
外部DBシングル構成 (single/extdb) で
docker compose pullが以下のエラーで停止する、という問い合わせがあった。2026/07/10 リリースで導入した
:?による必須化 (#98) が原因。docker compose は変数展開を compose ファイル読み込み時に一括で実施するため、upだけでなくpull/config/down/ps/logsなどすべてのサブコマンドで発火する (pullが接続先に接続しているわけではなく、ファイルのパース段階で停止している)。ドキュメントはいずれもupの文脈でしか説明しておらず、README 自身の手順どおりに進めても必ずエラーになっていた。変更内容
1.
.envによる指定を主手順にした (c5a614c/2b288ff)コマンドごとの前置き指定は実運用で現実的でないため、セットアップ手順の先頭で
.envを用意する流れに改めた。以降のpull/up -d/downは素のコマンドのままでよい。Environment.mdに「環境変数の指定方法」節を新設 (必須の環境変数の一覧 / 全コマンドで必要になる理由 /.envの書式と注意点).env主手順に再構成し、前置き指定は「参考:.envを使わない場合」に集約.env/.env.bak.*を.gitignoreに追加 (パスワードを平文で含むため。資格情報セットアップ支援スクリプト (init.sh) の導入 — 初期/再デプロイの簡便化と堅牢化 #104 からの先行取り込み).envの書式説明は Docker Compose v2.29.2 での実挙動を確認して記述している。シェルではなく compose が解釈するため、コマンド前置きでの指定とは扱いが異なる。.envの記述DATABASE_URL=pgsql://u:pa$ss@h:5432/dbpgsql://u:pa@h:5432/db($ssが変数参照として展開される)DATABASE_URL=pgsql://u:pa$$ss@h:5432/db$はエスケープされて維持DATABASE_URL='pgsql://u:pa$ss@h:5432/db'$は維持DATABASE_URL=pgsql://u:p@h:5432/db # comment#以降はコメントとして無視2.
cluster/swarmのDATABASE_URL必須化を取り止めた (e9ae9f3)本構成では
setup_stack.shが要否判定 (未指定ならDATABASE_HOSTから既定値を組み立て、いずれも無ければエラー停止) を行なった上でdocker-swarm.ymlを生成する。compose ファイル側の:?はこれと重複しており、README の環境変数表の記述 (「未指定時はDATABASE_HOSTからデフォルト値を構築します」) とも矛盾していた。またdocker stack deployには用いないdocker compose pullまで停止させていた。x-required-db-envと 3 サービスの<<:マージを削除し、#98 以前の状態に戻した。extdb / jobmngrd で必須を維持したのは、未指定時のフォールバック先が内部コンテナ (
postgres/rabbitmq) で、これらの構成には存在しないため。黙って起動すると名前解決エラーで kengine が再起動ループに入り、原因の分かりにくい失敗になる。3.
:?のエラーメッセージを改善した (26ac0f3)README を読まずにコマンドを実行した場合、このメッセージが唯一の導線になるため、値の例だけでなく (1)
up以外でも必要であること (2).envに書けば以後不要になること (3)Environment.mdへの誘導を含めた。動作確認
環境変数・
.envなしの状態でdocker compose config -q/docker compose pullを実行:ke2/single/extdbke2/extra/jobmngrdAMQP_URL)ke2/cluster/swarmke2/single/basicあわせて確認した項目:
.env作成後、extdb / jobmngrd で追加指定なしにconfig -qが通ることSHARED_DIR=... ./setup_stack.shがdocker-swarm.ymlを生成でき、既定でDATABASE_URL=pgsql://kompira:kompira@host.docker.internal:9999/kompira、DATABASE_HOST=10.20.0.100指定時に...@10.20.0.100:9999/kompiraになること (README の記述どおり).envがgit check-ignoreで除外されること補足
init.sh導入) との競合は 資格情報セットアップ支援スクリプト (init.sh) の導入 — 初期/再デプロイの簡便化と堅牢化 #104 側で解決する方針。 本 PR を先にリリースし、docker compose pull→./init.shの順序修正は既に 資格情報セットアップ支援スクリプト (init.sh) の導入 — 初期/再デプロイの簡便化と堅牢化 #104 ブランチへ入れてある。