Add reusable devcontainer setup - #2
Conversation
|
Your cubic subscription is currently inactive. Please reactivate your subscription to receive AI reviews and use cubic. |
WalkthroughA reusable devcontainer configuration and feature were introduced, including documentation and setup scripts. The Changes
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
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit 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. Note ⚡️ Faster reviews with cachingCodeRabbit 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 ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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.jsonuses Microsoft's Ubuntu base image and references local feature for configuration - Added
features/common/install.shscript intelligently handles file ownership between root/non-root users - New
features/common/devcontainer-feature.jsondefines version 0.2.0 of the config-base feature - Japanese documentation in
.devcontainer/README.mdexplains 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": {} |
There was a problem hiding this comment.
style: Relative path '../features/common' may break if .devcontainer directory is copied to other repos. Consider using an absolute reference or documenting this requirement.
| chown -R "$USERNAME":"$USERNAME" "$TARGET_HOME/.zsh" "$TARGET_HOME/.zprofile" \ | ||
| "$TARGET_HOME/.zshrc" "$TARGET_HOME/git" |
There was a problem hiding this comment.
style: Consider using -h flag with chown to avoid following symbolic links
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
features/common/devcontainer-feature.json (1)
1-6: Add schema and supported platforms metadata
Including a$schemareference and aplatformsproperty 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 usersyncfor robustness
Logging progress helps with debugging, andrsyncpreserves 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
📒 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.devcontainerto 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.devcontainerdirectory and feature for VS Code Dev Containers without heavy dependencies.
| { | ||
| "name": "Config Base Container", | ||
| "image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
| "features": { | ||
| "../features/common": {} | ||
| } | ||
| } |
There was a problem hiding this comment.
🛠️ 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.
| { | |
| "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.
| TARGET_HOME="$HOME" | ||
| if [ "$(id -u)" = 0 ] && [ -n "$USERNAME" ] && [ -d "/home/$USERNAME" ]; then | ||
| TARGET_HOME="/home/$USERNAME" | ||
| fi |
There was a problem hiding this comment.
🛠️ 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
fiThis 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.
## 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>
* 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>
|
🎉 This PR is included in version 1.16.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Testing
bash -n features/common/install.shjq . .devcontainer/devcontainer.jsonjq . features/common/devcontainer-feature.jsonSummary by CodeRabbit
New Features
Documentation