Skip to content

Add reusable devcontainer setup - #2

Closed
keito4 wants to merge 1 commit into
masterfrom
cq5v4t-codex
Closed

Add reusable devcontainer setup#2
keito4 wants to merge 1 commit into
masterfrom
cq5v4t-codex

Conversation

@keito4

@keito4 keito4 commented May 21, 2025

Copy link
Copy Markdown
Owner

Summary

  • create reusable devcontainer config using Dev Container Features
  • document how to use it in README
  • copy minimal shell configs and Git settings instead of running full import script

Testing

  • bash -n features/common/install.sh
  • jq . .devcontainer/devcontainer.json
  • jq . features/common/devcontainer-feature.json

Summary by CodeRabbit

  • New Features

    • Introduced a reusable development container setup for consistent development environments.
    • Added a feature that automatically copies shell functions and Git configuration into the container, ensuring minimal setup without installing heavy dependencies.
  • Documentation

    • Added and updated documentation to explain the new devcontainer setup, usage instructions, and included features.

@cubic-dev-ai

cubic-dev-ai Bot commented May 21, 2025

Copy link
Copy Markdown

Your cubic subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use cubic.

@coderabbitai

coderabbitai Bot commented May 21, 2025

Copy link
Copy Markdown

Walkthrough

A reusable devcontainer configuration and feature were introduced, including documentation and setup scripts. The .devcontainer directory now provides a standardized development environment using a base Ubuntu image and a custom feature that copies shell and Git configurations into the user's home directory, without installing heavy dependencies. All changes are limited to configuration and documentation.

Changes

File(s) Change Summary
.devcontainer/README.md Added documentation for the shared devcontainer component, usage instructions, and setup notes.
.devcontainer/devcontainer.json Introduced a devcontainer configuration using a base Ubuntu image and referencing a custom feature.
README.md Updated to document the new .devcontainer directory, its purpose, and usage details.
features/common/devcontainer-feature.json Added metadata describing the new "Config Base" devcontainer feature.
features/common/install.sh Added a script to copy shell and Git configuration files to the user's home directory, adjusting permissions if needed.

Sequence Diagram(s)

sequenceDiagram
    participant VSCode
    participant Devcontainer
    participant FeatureInstallScript as install.sh
    participant UserHome

    VSCode->>Devcontainer: Start devcontainer using devcontainer.json
    Devcontainer->>FeatureInstallScript: Run install.sh from features/common
    FeatureInstallScript->>UserHome: Copy shell and Git config files
    FeatureInstallScript->>UserHome: Adjust ownership if running as root
    Note right of UserHome: User environment is now configured
Loading

Poem

In the warren of code, a new home appears,
With scripts and configs, it calms all our fears.
No heavy brews, just a shell so neat—
Git and Zsh settings, a dev’s little treat.
Hop in, set up, let your code journey start,
This devcontainer’s built with a rabbit’s big heart!
🐇✨

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@greptile-apps greptile-apps 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.

PR Summary

Introduces a reusable devcontainer setup with minimal configuration, focusing on essential shell and Git settings without heavy dependencies like Homebrew.

  • New .devcontainer/devcontainer.json uses Microsoft's Ubuntu base image and references local feature for configuration
  • Added features/common/install.sh script intelligently handles file ownership between root/non-root users
  • New features/common/devcontainer-feature.json defines version 0.2.0 of the config-base feature
  • Japanese documentation in .devcontainer/README.md explains reuse options: direct copy or reference
  • Script copies only core configs (~/.zsh/functions, .zprofile, .zshrc, git/) without installing packages

5 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

"name": "Config Base Container",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"../features/common": {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Relative path '../features/common' may break if .devcontainer directory is copied to other repos. Consider using an absolute reference or documenting this requirement.

Comment on lines +23 to +24
chown -R "$USERNAME":"$USERNAME" "$TARGET_HOME/.zsh" "$TARGET_HOME/.zprofile" \
"$TARGET_HOME/.zshrc" "$TARGET_HOME/git"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

style: Consider using -h flag with chown to avoid following symbolic links

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
features/common/devcontainer-feature.json (1)

1-6: Add schema and supported platforms metadata
Including a $schema reference and a platforms property will enable JSON validation and clarify which environments this feature targets.
Suggested diff:

 {
+  "$schema": "https://raw.githubusercontent.com/devcontainers/features/main/schema/devcontainer-feature.json",
     "id": "config-base",
     "version": "0.2.0",
+  "platforms": [
+    "linux"
+  ],
     "name": "Config Base",
     "description": "Copies shell functions and Git config from this repository without installing heavy dependencies."
 }
features/common/install.sh (1)

13-20: Add informative logging and use rsync for robustness
Logging progress helps with debugging, and rsync preserves metadata and handles existing files more gracefully. For example:

+echo "Copying shell functions and Git config to $TARGET_HOME"
-mkdir -p "$TARGET_HOME/.zsh"
-cp -r "$REPO_ROOT/.zsh/functions" "$TARGET_HOME/.zsh/"
-cp "$REPO_ROOT/dot/.zprofile" "$TARGET_HOME/"
-cp "$REPO_ROOT/dot/.zshrc" "$TARGET_HOME/"
-cp -r "$REPO_ROOT/git" "$TARGET_HOME/"
+mkdir -p "$TARGET_HOME/.zsh/functions"
+# Use rsync to sync files and preserve permissions
+rsync -a "$REPO_ROOT/.zsh/functions/" "$TARGET_HOME/.zsh/functions/"
+rsync -a "$REPO_ROOT/dot/.zprofile" "$TARGET_HOME/.zprofile"
+rsync -a "$REPO_ROOT/dot/.zshrc" "$TARGET_HOME/.zshrc"
+rsync -a "$REPO_ROOT/git/" "$TARGET_HOME/git/"
+echo "Configuration copy complete."
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 2428dbf and 9b690b6.

📒 Files selected for processing (5)
  • .devcontainer/README.md (1 hunks)
  • .devcontainer/devcontainer.json (1 hunks)
  • README.md (2 hunks)
  • features/common/devcontainer-feature.json (1 hunks)
  • features/common/install.sh (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~13-~13: Loose punctuation mark.
Context: ...ent tools and systems. - .devcontainer: Provides a reusable devcontainer config...

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Greptile Review
🔇 Additional comments (3)
.devcontainer/README.md (1)

1-17: Documentation is clear and concise
The Japanese README clearly explains usage of the shared Dev Container component, includes practical code snippets, and emphasizes minimal dependency installation. Great work!

README.md (2)

13-13: Approve addition of .devcontainer to directory structure
The new entry accurately reflects the reusable devcontainer setup in the project overview.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~13-~13: Loose punctuation mark.
Context: ...ent tools and systems. - .devcontainer: Provides a reusable devcontainer config...

(UNLIKELY_OPENING_PUNCTUATION)


40-44: Approve Devcontainer usage documentation
The new “Devcontainer” section clearly explains how to leverage the .devcontainer directory and feature for VS Code Dev Containers without heavy dependencies.

Comment on lines +1 to +7
{
"name": "Config Base Container",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"../features/common": {}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Explicitly set the remoteUser
Without specifying remoteUser, the container may default to root, causing the feature to apply configs to /root instead of the intended non-root user’s home directory. I recommend adding:

 {
     "name": "Config Base Container",
     "image": "mcr.microsoft.com/devcontainers/base:ubuntu",
+    "remoteUser": "vscode",
     "features": {
         "../features/common": {}
     }
 }
📝 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.

Suggested change
{
"name": "Config Base Container",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"../features/common": {}
}
}
{
"name": "Config Base Container",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"remoteUser": "vscode",
"features": {
"../features/common": {}
}
}
🤖 Prompt for AI Agents
In .devcontainer/devcontainer.json lines 1 to 7, the remoteUser property is
missing, which causes the container to default to root and apply configurations
to /root instead of the intended non-root user's home directory. Add the
"remoteUser" property with the appropriate non-root username to ensure features
apply to the correct user's environment.

Comment on lines +8 to +11
TARGET_HOME="$HOME"
if [ "$(id -u)" = 0 ] && [ -n "$USERNAME" ] && [ -d "/home/$USERNAME" ]; then
TARGET_HOME="/home/$USERNAME"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Detect non-root user more reliably
Relying solely on $USERNAME may not work in all environments. It’s safer to prefer $SUDO_USER (when run via sudo) and then fall back to $USERNAME. For example:

 if [ "$(id -u)" = 0 ]; then
-  if [ -n "$USERNAME" ] && [ -d "/home/$USERNAME" ]; then
-    TARGET_HOME="/home/$USERNAME"
+  # Determine non-root user: prefer SUDO_USER, then USERNAME
+  if [ -n "$SUDO_USER" ] && [ -d "/home/$SUDO_USER" ]; then
+    USER="$SUDO_USER"
+  elif [ -n "$USERNAME" ] && [ -d "/home/$USERNAME" ]; then
+    USER="$USERNAME"
+  fi
+  if [ -n "$USER" ]; then
+    TARGET_HOME="/home/$USER"
+  fi
 fi

This change ensures configuration lands in the correct user’s home.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In features/common/install.sh around lines 8 to 11, improve the detection of the
non-root user by checking the SUDO_USER environment variable first when the
script is run with sudo, and then falling back to USERNAME if SUDO_USER is not
set. Update the logic to set TARGET_HOME based on the home directory of
SUDO_USER if available and valid, otherwise use USERNAME, ensuring the
configuration is placed in the correct user's home directory.

@keito4 keito4 closed this May 21, 2025
keito4 added a commit that referenced this pull request Dec 30, 2025
## Summary
- Install shellcheck in DevContainer
- Add npm script for running shellcheck
- Integrate shellcheck into CI pipeline
- Add comprehensive documentation for Issue #2

## Changes
- `.devcontainer/Dockerfile`: Add shellcheck to apt-get install
- `package.json`: Add "shellcheck" script
- `.github/workflows/ci.yml`: Add shellcheck step to CI
- `issues/tech-debt-002-shellcheck.md`: Implementation plan
- `issues/tech-debt-002-implementation.md`: Completion report

## Benefits
- Detect shell script bugs before runtime
- Catch quoting, path expansion, and POSIX compatibility issues
- Expected ROI: 234% (first year)
- Annual cost savings: $2,880

## Ref
- Tech Debt Issue #2
- Priority: High (Quick Win)
- Effort: 5.75 hours
- ROI: 234%

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
keito4 added a commit that referenced this pull request Dec 30, 2025
* feat: Add shellcheck static analysis for shell scripts

## Summary
- Install shellcheck in DevContainer
- Add npm script for running shellcheck
- Integrate shellcheck into CI pipeline
- Add comprehensive documentation for Issue #2

## Changes
- `.devcontainer/Dockerfile`: Add shellcheck to apt-get install
- `package.json`: Add "shellcheck" script
- `.github/workflows/ci.yml`: Add shellcheck step to CI
- `issues/tech-debt-002-shellcheck.md`: Implementation plan
- `issues/tech-debt-002-implementation.md`: Completion report

## Benefits
- Detect shell script bugs before runtime
- Catch quoting, path expansion, and POSIX compatibility issues
- Expected ROI: 234% (first year)
- Annual cost savings: $2,880

## Ref
- Tech Debt Issue #2
- Priority: High (Quick Win)
- Effort: 5.75 hours
- ROI: 234%

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

* fix: Exclude zsh scripts from shellcheck validation

shellcheck does not support zsh syntax, only sh/bash/dash/ksh.
Exclude the following zsh scripts from shellcheck:
- script/import.sh
- script/export.sh
- script/credentials.sh
- script/brew-deps.sh
- script/lib/platform.sh
- script/lib/devcontainer.sh
- script/credentials/providers/op.sh

Only bash scripts are now checked:
- script/setup-claude.sh
- script/update-libraries.sh
- script/verify-container-setup.sh
- script/commit_changes.sh
- script/fix-container-plugins.sh
- script/post-create-plugins.sh
- script/version.sh
- script/install-claude-plugins.sh

Resolves CI failure: SC1071 (ShellCheck only supports sh/bash/dash/ksh)

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.16.0 🎉

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

codex released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant