Skip to content

Restore postCreateContainer.sh execution on container init#132

Merged
toshi0806 merged 1 commit into
mainfrom
fix-postcreate-lifecycle-hook
Jun 24, 2026
Merged

Restore postCreateContainer.sh execution on container init#132
toshi0806 merged 1 commit into
mainfrom
fix-postcreate-lifecycle-hook

Conversation

@toshi0806

Copy link
Copy Markdown
Member

問題

新規に clone してフォルダを開いた際、コンテナ初期化直後の bin/.postCreateContainer.sh が起動しない。

原因

#111 (8827714) で setup スクリプトのライフサイクルフックが postCreateCommand から onCreateCommand に変更されたことが原因。

このリポジトリでは、スクリプト本体 bin/.postCreateContainer.sh とその依存物(lib/.support/makefilebashrc_additions.shatcoder-cli-nodejs の設定)が すべて docker-compose.yml で宣言されたホスト側 bind mount 上にある。

  • onCreateCommand はコンテナ作成ライフサイクルの最初に実行され、ワークスペース/bind mount が利用可能になる前に走る → スクリプトファイルが見つからず実行されない。
  • さらに TTY を持たないため、スクリプト終盤の対話的 aclogin プロンプトもスキップされ、出力も作成ログに隠れてユーザーから見えない。

修正

ライフサイクルフックを postCreateCommand に戻す(#111 以前の状態)。postCreateCommand はマウント確立後・対話ターミナルありで実行されるため、意図したセットアップ動作が復元される。将来また onCreateCommand に変えて壊さないよう、理由をコメントとして追記した。

動作確認

Dev Containers: Rebuild Container、または新規 clone で開き直すと、セットアップスクリプトが実行され「準備が完了しました」メッセージと aclogin プロンプトが表示されることを確認できる。

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.

@github-actions github-actions 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.

コードの変更内容を確認しました。onCreateCommand から postCreateCommand への変更は、PRの説明に記載された技術的な理由(bind mountの可用性とTTYの必要性)に基づいており、適切な修正です。コメントも将来の混乱を防ぐために十分な説明が追加されています。

// 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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✨ [POSITIVE] [POSITIVE] onCreateCommand から postCreateCommand に戻した理由を詳細なコメントとして残している点は非常に良い実践です。bind mountの可用性とTTYの必要性という2つの重要な理由が明記されており、将来の開発者が誤って onCreateCommand に変更してしまうリスクを軽減できます。

@toshi0806 toshi0806 merged commit bbab5f7 into main Jun 24, 2026
1 check passed
@toshi0806 toshi0806 deleted the fix-postcreate-lifecycle-hook branch June 24, 2026 06:06
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