Give Corepack a user-writable Layer 3 cache - #9
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideConfigures Corepack to use a user-owned cache in the Layer 3 user image and extends the devBench harness to validate unprivileged pnpm/Corepack operation and cache writability. Sequence diagram for user-writable Corepack cache and pnpm validationsequenceDiagram
actor DevBenchTest
participant Shell
participant pnpm
participant Corepack
participant Filesystem
DevBenchTest->>Shell: run test.sh
Shell->>Shell: set COREPACK_HOME=/home/$USERNAME/.cache/corepack
Shell->>Filesystem: mkdir -p COREPACK_HOME
Shell->>pnpm: pnpm --version
pnpm->>Corepack: resolve pnpm version via Corepack
Corepack->>Filesystem: write cache under COREPACK_HOME
Filesystem-->>Corepack: cache write succeeds (user-owned)
Corepack-->>pnpm: provide pnpm 11.17.0
pnpm-->>Shell: print version
Shell-->>DevBenchTest: report unprivileged pnpm/Corepack operation success
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Setting COREPACK_HOME globally in the Dockerfile means root processes in the container will also use a cache under the non-root user’s home; consider scoping COREPACK_HOME to the non-root user (e.g., via that user’s shell profile) to avoid unexpected permission behavior when running Corepack as root.
- The Corepack cache test in devcontainer.test/test.sh assumes HOME is always /home/$USERNAME; if HOME can be overridden in any harness scenario, consider checking directory ownership and writability more directly rather than strict path equality.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Setting COREPACK_HOME globally in the Dockerfile means root processes in the container will also use a cache under the non-root user’s home; consider scoping COREPACK_HOME to the non-root user (e.g., via that user’s shell profile) to avoid unexpected permission behavior when running Corepack as root.
- The Corepack cache test in devcontainer.test/test.sh assumes HOME is always /home/$USERNAME; if HOME can be overridden in any harness scenario, consider checking directory ownership and writability more directly rather than strict path equality.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
This PR configures Corepack to use a user-writable cache location in the Layer 3 user image and extends the devcontainer test harness/docs to validate unprivileged pnpm/Corepack behavior.
Changes:
- Set
COREPACK_HOMEin the Layer 3 user image and pre-create the cache directory under the user’s home. - Extend the devcontainer test harness to run
pnpm --versionand assert Corepack cache ownership/writability. - Update the devcontainer test README to mention pnpm/Corepack validation and the user-writable cache behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| user-layer/Dockerfile | Sets COREPACK_HOME and pre-creates the cache directory in the Layer 3 user image; bumps layer version label. |
| devBenches/devcontainer.test/test.sh | Adds pnpm/Corepack checks to ensure cache location is user-owned/writable under unprivileged execution. |
| devBenches/devcontainer.test/README.md | Updates harness documentation to reflect pnpm/Corepack coverage and cache behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Corepack downloads package-manager shims and versions on demand. Keep its | ||
| # mutable cache in the Layer 3 user's home rather than the root-owned cache | ||
| # inherited from a shared base image. | ||
| ENV COREPACK_HOME=/home/${USERNAME}/.cache/corepack | ||
|
|
| test_tool "Corepack cache is user-owned and writable" \ | ||
| "test \"\$COREPACK_HOME\" = \"\$HOME/.cache/corepack\" && test -d \"\$COREPACK_HOME\" && test -w \"\$COREPACK_HOME\"" |
| - Python 3.x with pip and development tools (black, flake8, isort, pylint, pytest, ipython) | ||
| - Node.js LTS with npm and yarn | ||
| - Node.js LTS with npm, yarn, and a user-writable Corepack cache for pnpm | ||
| - Python package managers (uv) |
There was a problem hiding this comment.
Fixed in 781193d: Layer 1a now lists only its Node tooling, and a separate paragraph attributes the effective-user Corepack cache to Layer 3.
There was a problem hiding this comment.
Correction: the documentation fix is commit 1b9311c.
…x/user-corepack-cache # Conflicts: # devBenches/devcontainer.test/test.sh
|
Addressed Sourcery feedback at b837741: Corepack now derives its cache from the effective user at runtime, so root and bench users remain isolated. The harness now checks actual cache ownership and writability rather than strict HOME equality. @sourcery-ai review |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| # Respect an explicit caller override. Replace only the shared image default, | ||
| # which is root-owned and therefore unusable by Layer 3 runtime users. | ||
| case "${COREPACK_HOME:-}" in | ||
| ""|/opt/corepack) | ||
| runtime_home=$(getent passwd "$(id -u)" | cut -d: -f6) | ||
| if [ -z "$runtime_home" ]; then | ||
| echo "Could not determine the effective user's home directory" >&2 | ||
| exit 1 | ||
| fi | ||
| COREPACK_HOME="$runtime_home/.cache/corepack" | ||
| export COREPACK_HOME | ||
| ;; | ||
| esac | ||
|
|
||
| mkdir -p "$COREPACK_HOME" | ||
| exec "/usr/bin/$command_name" "$@" |
There was a problem hiding this comment.
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| case "${COREPACK_HOME:-}" in | ||
| ""|/opt/corepack) | ||
| runtime_home=$(getent passwd "$(id -u)" | cut -d: -f6) | ||
| if [ -z "$runtime_home" ]; then | ||
| echo "Could not determine the effective user's home directory" >&2 | ||
| exit 1 | ||
| fi | ||
| COREPACK_HOME="$runtime_home/.cache/corepack" | ||
| export COREPACK_HOME | ||
| ;; | ||
| esac |
Summary
Validation
git diff --checkcorepacktestpnpm --versiondownloaded pnpm 11.17.0 into/home/corepacktest/.cache/corepackSummary by Sourcery
Configure Corepack to use a user-owned cache in the Layer 3 user image and validate unprivileged pnpm/Corepack behavior in the dev container harness.
New Features:
Enhancements:
Documentation:
Tests: