Skip to content

fix: setup-claude.shを/usr/local/binに配置してfeatures適用後も保持 - #182

Merged
keito4 merged 1 commit into
mainfrom
fix/move-setup-script-to-usr-local-bin
Dec 26, 2025
Merged

fix: setup-claude.shを/usr/local/binに配置してfeatures適用後も保持#182
keito4 merged 1 commit into
mainfrom
fix/move-setup-script-to-usr-local-bin

Conversation

@keito4

@keito4 keito4 commented Dec 26, 2025

Copy link
Copy Markdown
Owner

問題

DevContainerで/tmp/setup-claude.shが存在しないため、プラグインがインストールされない問題がありました。

根本原因

  1. v1.8.1イメージには/tmp/setup-claude.shが含まれている(確認済み)

  2. しかし、devcontainer.jsonで以下のfeaturesを指定:

    • docker-in-docker
    • git
    • op (1Password)
    • github-cli
    • python
  3. DevContainerがfeaturesを適用する際、新しいレイヤーを作成し、/tmpディレクトリがクリアされる

解決策

/tmpではなく永続的なディレクトリ/usr/local/binにスクリプトを配置します。

変更内容

1. Dockerfile

変更前:

COPY --chown=vscode:vscode script/setup-claude.sh /tmp/setup-claude.sh

変更後:

COPY --chown=root:root script/setup-claude.sh /usr/local/bin/setup-claude.sh
RUN chmod +x /usr/local/bin/setup-claude.sh

2. devcontainer.json

変更前:

"postCreateCommand": "... && /tmp/setup-claude.sh",

変更後:

"postCreateCommand": "... && /usr/local/bin/setup-claude.sh",

期待される動作

  • /usr/local/bin/setup-claude.shがfeatures適用後も保持される
  • ✅ DevContainer起動時にプラグインが正しくインストールされる
  • /pluginコマンドで9個のプラグインが表示される

Test plan

  • CI/CDでイメージビルドが成功することを確認
  • 新バージョン(v1.8.2)がリリースされることを確認
  • pulse_surveyで新イメージを使用してプラグインが表示されることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated development environment initialization to ensure proper setup script execution and consistency across development container instances.

✏️ Tip: You can customize this high-level summary in your review settings.

## 問題
- /tmp/setup-claude.shがDevContainerのfeatures適用時にクリアされる
- docker-in-docker, git, python等のfeaturesを追加すると/tmpが初期化される

## 根本原因
- DevContainerがfeaturesを適用する際、新しいレイヤーを作成
- このプロセスで/tmpディレクトリの内容が失われる

## 解決策
- setup-claude.shを/usr/local/binに配置(永続的なディレクトリ)
- 実行権限を付与
- postCreateCommandで/usr/local/bin/setup-claude.shを呼び出す

## 変更内容
- Dockerfile: /tmp/setup-claude.sh → /usr/local/bin/setup-claude.sh
- devcontainer.json: postCreateCommandのパスを更新

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@keito4
keito4 merged commit 26eb8d8 into main Dec 26, 2025
3 of 4 checks passed
@coderabbitai

coderabbitai Bot commented Dec 26, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The setup-claude.sh script is relocated from /tmp/setup-claude.sh to /usr/local/bin/setup-claude.sh in the Docker image, made executable with a RUN command, and the devcontainer postCreateCommand is updated to invoke it from the new location.

Changes

Cohort / File(s) Summary
DevContainer Docker Configuration
.devcontainer/Dockerfile, .devcontainer/devcontainer.json
Script relocation and invocation update: setup-claude.sh copied to /usr/local/bin with root ownership and explicit executable permission, replacing /tmp location. postCreateCommand reference updated to invoke from new path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

released

Poem

🐰 A script hops from /tmp's fleeting ground,
To /usr/local/bin, safe and sound!
With executable permissions set just right,
The DevContainer setup shines bright! ✨

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/move-setup-script-to-usr-local-bin

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e98ca4d and 86610c6.

📒 Files selected for processing (2)
  • .devcontainer/Dockerfile
  • .devcontainer/devcontainer.json

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@keito4
keito4 deleted the fix/move-setup-script-to-usr-local-bin branch December 26, 2025 03:58
@claude

claude Bot commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

プルリクエスト レビュー

このPRを確認しました。/tmpから/usr/local/binへのスクリプト移動は適切な解決策です。以下、詳細なレビュー結果です。


✅ 良い点

1. 根本原因の正確な理解と適切な解決策

  • DevContainer featuresが新しいレイヤーを作成する際に/tmpがクリアされる問題を正確に特定
  • /usr/local/binへの移動は永続化の標準的なアプローチで適切

2. 適切な権限設定

COPY --chown=root:root script/setup-claude.sh /usr/local/bin/setup-claude.sh
RUN chmod +x /usr/local/bin/setup-claude.sh
  • システムスクリプトとしてroot:root所有権は正しい
  • 実行権限の明示的な付与も適切

3. 詳細なPR説明

  • 問題・根本原因・解決策が明確に文書化されている
  • Before/Afterの比較で変更内容が理解しやすい

🔍 改善提案

1. セキュリティ考慮事項 (MEDIUM)

問題点: .devcontainer/Dockerfile:80-81

COPY --chown=root:root script/setup-claude.sh /usr/local/bin/setup-claude.sh
RUN chmod +x /usr/local/bin/setup-claude.sh

推奨: スクリプトの実行権限を最小化

COPY --chown=root:root --chmod=755 script/setup-claude.sh /usr/local/bin/setup-claude.sh

理由:

  • COPYとchmodを1ステップに統合し、レイヤー数を削減
  • 755権限で所有者以外は読み取り・実行のみに制限

2. スクリプトの堅牢性向上 (LOW)

現状: script/setup-claude.sh:25-28

if ! command -v claude &> /dev/null; then
    log_warn "Claude CLI が見つかりません。プラグインのインストールはスキップされます。"
    exit 0
fi

推奨: より詳細なエラーハンドリング

if ! command -v claude &> /dev/null; then
    log_warn "Claude CLI が見つかりません。プラグインのインストールはスキップされます。"
    log_info "PATH: $PATH"
    exit 0
fi

理由: デバッグ時にPATH情報があると問題の特定が容易

3. CI/CD 検証 (HIGH)

test plan チェックリスト未完了:

  • CI/CDでイメージビルドが成功することを確認
  • 新バージョン(v1.8.2)がリリースされることを確認
  • pulse_surveyで新イメージを使用してプラグインが表示されることを確認

推奨アクション:

  1. CI/CDパイプラインの成功を確認してからマージ
  2. リリース後の動作確認を実施
  3. チェックリストを完了させる

4. テストカバレッジ (MEDIUM)

現状: DevContainer関連の自動テストが見当たらない

推奨:

# .github/workflows/devcontainer-test.yml (新規作成を検討)
name: DevContainer Validation
on: [pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build DevContainer
        run: docker build -f .devcontainer/Dockerfile .
      - name: Verify setup-claude.sh location
        run: docker run --rm $(docker build -q -f .devcontainer/Dockerfile .) ls -la /usr/local/bin/setup-claude.sh

理由: インフラ変更の回帰テストを自動化し、CLAUDE.mdの70%カバレッジ要件に近づける


📋 コードスタイル

Conventional Commits準拠 ✅

fix: setup-claude.shを/usr/local/binに配置してfeatures適用後も保持
  • プレフィックスfix:は適切(バグ修正)
  • 日本語サマリは許容範囲(CLAUDE.md 3.3)

🔒 セキュリティチェック

良好な点 ✅

  1. 認証情報の適切な処理

    • install-claude-plugins.sh:82で認証情報を削除
    • BuildKit secretの使用
  2. 最小権限の原則

    • setup-claude.shはvscodeユーザーとして実行
    • rootへのエスカレーション無し

懸念点なし


🎯 パフォーマンス

影響評価

  • ビルド時間: 変更なし(COPYコマンドの対象変更のみ)
  • 実行時間: 変更なし(スクリプトの場所のみ変更)
  • イメージサイズ: +0 bytes(ファイル移動のみ)

📊 総合評価

項目 評価 コメント
コード品質 ⭐⭐⭐⭐ 適切な実装、軽微な改善提案あり
セキュリティ ⭐⭐⭐⭐⭐ 問題なし、認証情報処理も適切
パフォーマンス ⭐⭐⭐⭐⭐ 影響なし
テストカバレッジ ⭐⭐⭐ DevContainer自動テストの追加を推奨
ドキュメント ⭐⭐⭐⭐⭐ PR説明が非常に詳細

✨ 推奨アクション

マージ前に実施すべき項目

  1. COPY --chmod=755 への変更(セキュリティ向上)
  2. CI/CD成功確認(test plan完了)

将来的な改善項目(別PR推奨)

  1. DevContainer検証用の自動テスト追加
  2. スクリプトデバッグ情報の拡充

🚀 結論

承認推奨: このPRは技術的に健全で、明確な問題を適切に解決しています。

上記の軽微な改善提案を適用すれば、さらに堅牢になりますが、現状でもマージ可能な品質です。CI/CD成功確認後のマージを推奨します。


レビュアー: Claude Sonnet 4.5
レビュー日時: 2025-12-26
参照ガイドライン: CLAUDE.md (TDD 70%+カバレッジ、Conventional Commits、Security SAST)

@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.8.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant