refactor: Replace custom Dockerfile with feature-based devcontainer#7
Conversation
📝 WalkthroughWalkthroughDevcontainer switched from a custom build Dockerfile to an image-plus-docker-compose setup: Changes
Sequence Diagram(s)mermaid Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.devcontainer/devcontainer.json:
- Line 17: The mount in the devcontainer bind string uses ${localEnv:APPDATA}/gh
which is the wrong Windows folder; update the source portion of the bind entry
(the string shown in the diff) to point to the GitHub CLI default folder by
replacing "${localEnv:APPDATA}/gh" with "${localEnv:APPDATA}/GitHub CLI" so the
container mounts the correct Windows config directory and commands like `gh auth
status` work inside the container.
- Line 21: The postCreateCommand currently runs "Install-Module -Name Pester
-Force -SkipPublisherCheck" which relies on implicit scope resolution; update
the command referenced by postCreateCommand to explicitly add "-Scope
CurrentUser" to the Install-Module invocation so Pester is installed for the
vscode/non-elevated user reliably across PowerShellGet versions.
There was a problem hiding this comment.
Pull request overview
This PR refactors the devcontainer configuration to use official devcontainer features instead of a custom Dockerfile, aiming to simplify the setup for Claude Code and PowerShell development.
Changes:
- Replaced custom 58-line Dockerfile with official devcontainer features (common-utils, github-cli, claude-code)
- Switched from PowerShell LTS Ubuntu 22.04 to PowerShell 7.5 Ubuntu 24.04 base image
- Added host config mounts for GitHub CLI and Claude authentication
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| .devcontainer/devcontainer.json | Complete refactor to use features-based configuration with simplified setup and new host config mounts |
| .devcontainer/Dockerfile | Removed custom Dockerfile in favor of devcontainer features |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6e5e3d6 to
f50388b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.devcontainer/devcontainer.json:
- Around line 18-19: The devcontainer mount uses the Windows-only environment
variable ${localEnv:USERPROFILE}, which will be empty on macOS/Linux and cause
Docker mount failures; update .devcontainer/devcontainer.json to avoid directly
concatenating HOME and USERPROFILE and instead implement a cross-platform
approach: either document this as Windows-only, or replace the static mount
entries with a conditional solution such as adding an initializeCommand that
detects the host OS and sets a DEV_CONTAINER_CLAUDE_PATH (or similar) env var
before mounts are evaluated, or move the bind logic into a devcontainer feature
or init script that only creates the bind/mount when the resolved host path is
non-empty; reference the existing mount lines using ${localEnv:USERPROFILE} and
${localEnv:HOME} when making the conditional logic so the change targets those
exact variables.
Replace custom Dockerfile with feature-based approach: - Use official ghcr.io/anthropics/devcontainer-features/claude-code - Mount host Claude and GitHub CLI configs for seamless auth - Simplify to PowerShell 7.5 base image with devcontainer features Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f50388b to
d51d1d4
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.devcontainer/devcontainer.json:
- Around line 2-3: The devcontainer "image" entry currently uses the
non-existent tag "mcr.microsoft.com/powershell:7-ubuntu-24.04"; update the
"image" property value to a valid PowerShell tag such as
"mcr.microsoft.com/powershell:7-ubuntu-22.04" or
"mcr.microsoft.com/powershell:latest" so the container can be pulled
successfully, leaving the rest of .devcontainer/devcontainer.json unchanged.
Replace Windows-only ${localEnv:USERPROFILE} mounts with a Docker
Compose approach that works on Windows, macOS, and Linux. An
initializeCommand runs setup-host.ps1 to detect the host home
directory (USERPROFILE or HOME) and writes a .env file that Docker
Compose uses for volume mount variable substitution.
Also updates the PowerShell base image tag from the non-existent
7-ubuntu-24.04 to the floating ubuntu-24.04 tag, and adds a git
safe.directory config for the bind-mounted workspace.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @.devcontainer/docker-compose.yml:
- Line 8: The docker-compose entry uses the named volume gh-cli-config which
prevents host GitHub CLI credentials from being shared into the container;
either replace the named volume gh-cli-config with a bind mount of the host GH
CLI config (e.g. host ~/.config/gh -> container /home/vscode/.config/gh) if you
want host auth available, or keep the named volume but update docs/README to
state users must run gh auth login inside the devcontainer; locate the volume
reference gh-cli-config in the .devcontainer docker-compose service and change
to a bind mount or add documentation accordingly.
In @.devcontainer/setup-host.ps1:
- Around line 21-28: The .env values written via the $envContent here-string are
unquoted which breaks docker-compose when paths contain spaces; update the
$envContent generation (the here-string assigned to $envContent) to wrap each
variable value in quotes (e.g., CLAUDE_HOST_HOME="...") and ensure any internal
double quotes in $claudeHome/$workspace/$workspaceName are escaped before
writing, then continue to write to $envPath with Set-Content as before.
🧹 Nitpick comments (1)
.devcontainer/devcontainer.json (1)
6-6:initializeCommandrequirespwshon the host machine.This command runs before the container is created, so the host must have PowerShell 7+ (
pwsh) installed. Since this is a PowerShell module template, that's a reasonable assumption — but contributors on a Linux/macOS machine withoutpwshwill get an opaque error. Consider adding a note in the repo README or a fallback.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Drop powershell.codeFormatting.preset to use the default, remove gitlens and editorconfig from recommended extensions (no .editorconfig file exists in the repo). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
${localEnv:USERPROFILE}bind mounts to a cross-platform Docker Compose approach using a generated.envfile7-ubuntu-24.04tag to floatingubuntu-24.04Changes
.devcontainer/Dockerfile(custom build).devcontainer/docker-compose.yml— service definition with cross-platform volume mounts using${CLAUDE_HOST_HOME}from.env.devcontainer/setup-host.ps1—initializeCommandscript that detectsUSERPROFILE(Windows) orHOME(macOS/Linux) and writes.devcontainer/.env.devcontainer/devcontainer.json— switched fromimage/mountstodockerComposeFile/servicewithinitializeCommand; added git safe.directory for bind-mounted workspace; removed OTBS formatting preset.vscode/extensions.json— removed GitLens and EditorConfig recommendations.gitignore— added.devcontainer/.envHow cross-platform mounts work
initializeCommandrunssetup-host.ps1on the host before container creation.devcontainer/.env.envand substitutes${CLAUDE_HOST_HOME}in volume mount pathsTest plan
setup-host.ps1generates correct.envon Windowsdocker compose configresolves all volume paths correctlydevcontainer build --workspace-folder .succeedsdevcontainer up --workspace-folder .succeeds (workspace mount, features, postCreateCommand)🤖 Generated with Claude Code