Restore postCreateContainer.sh execution on container init#132
Merged
Conversation
Revert the setup-script lifecycle hook from onCreateCommand back to postCreateCommand (changed in #111). The script bin/.postCreateContainer.sh and all of its dependencies (lib/.support/makefile, bashrc_additions.sh, atcoder-cli-nodejs config) live on host bind mounts declared in docker-compose.yml. onCreateCommand runs early in the creation lifecycle, before the workspace/bind mounts are available, so the script could not be found and never ran on a fresh clone. It also runs without a TTY, so the interactive aclogin prompt was skipped and its output was hidden in the creation log. postCreateCommand runs after the mounts are ready and provides an interactive terminal, restoring the intended setup behavior. A comment is added to prevent regressing to onCreateCommand.
| // runs before the workspace/bind mounts are available, so the script would not be | ||
| // found. postCreateCommand runs after mounts are ready and provides a TTY for the | ||
| // interactive aclogin prompt. | ||
| "postCreateCommand": "bin/.postCreateContainer.sh 2>&1 | tee /tmp/postCreateContainer.log" |
There was a problem hiding this comment.
✨ [POSITIVE] [POSITIVE] onCreateCommand から postCreateCommand に戻した理由を詳細なコメントとして残している点は非常に良い実践です。bind mountの可用性とTTYの必要性という2つの重要な理由が明記されており、将来の開発者が誤って onCreateCommand に変更してしまうリスクを軽減できます。
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.
問題
新規に clone してフォルダを開いた際、コンテナ初期化直後の
bin/.postCreateContainer.shが起動しない。原因
#111 (
8827714) で setup スクリプトのライフサイクルフックがpostCreateCommandからonCreateCommandに変更されたことが原因。このリポジトリでは、スクリプト本体
bin/.postCreateContainer.shとその依存物(lib/.support/makefile、bashrc_additions.sh、atcoder-cli-nodejsの設定)が すべてdocker-compose.ymlで宣言されたホスト側 bind mount 上にある。onCreateCommandはコンテナ作成ライフサイクルの最初に実行され、ワークスペース/bind mount が利用可能になる前に走る → スクリプトファイルが見つからず実行されない。acloginプロンプトもスキップされ、出力も作成ログに隠れてユーザーから見えない。修正
ライフサイクルフックを
postCreateCommandに戻す(#111 以前の状態)。postCreateCommandはマウント確立後・対話ターミナルありで実行されるため、意図したセットアップ動作が復元される。将来またonCreateCommandに変えて壊さないよう、理由をコメントとして追記した。動作確認
Dev Containers: Rebuild Container、または新規 clone で開き直すと、セットアップスクリプトが実行され「準備が完了しました」メッセージと
acloginプロンプトが表示されることを確認できる。