Skip to content

Isolate Nx cache in Docker with dedicated volume#382

Open
cteyton wants to merge 3 commits into
mainfrom
claude/isolate-nx-docker-state-qqc974
Open

Isolate Nx cache in Docker with dedicated volume#382
cteyton wants to merge 3 commits into
mainfrom
claude/isolate-nx-docker-state-qqc974

Conversation

@cteyton

@cteyton cteyton commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Explanation

This change isolates the Nx cache and project graph in Docker containers by introducing a dedicated dev-nx Docker volume. This prevents Linux/Alpine containers and the host machine (e.g., macOS) from sharing and corrupting the same Nx store, which can occur due to platform differences.

The changes include:

  • Adding dev-nx volume to all relevant services in docker-compose.yml
  • Declaring the dev-nx volume in the volumes section
  • Updating migration scripts to clean up the new volume during Node.js version upgrades
  • Documenting the new behavior and reset procedures in CONTRIBUTING.md

Type of Change

  • Improvement/Enhancement
  • Documentation

Affected Components

  • Infrastructure: Docker Compose configuration
  • Documentation: Contributing guide
  • Scripts: Node.js migration scripts

Testing

No testing needed. This is a Docker configuration enhancement that:

  • Adds volume mounts to existing services (non-breaking)
  • Updates cleanup scripts to handle the new volume
  • Provides documentation for developers

The change is straightforward configuration and documentation updates with no code logic changes.

TODO List

  • Documentation Updated (CONTRIBUTING.md)

Reviewer Notes

The implementation adds the dev-nx:/packmind/.nx volume mount to 6 services:

  • nx-cloud
  • api
  • cli
  • api-build
  • api-build-prod
  • api-build-prod-arm64

Both migration scripts (downgrade_node22.sh and migrate_node24.sh) have been updated to clean up this volume during version transitions, ensuring a fresh Nx state after Node.js upgrades.

https://claude.ai/code/session_01559xduNDjnWKxCfXXY4Qmf

claude added 2 commits July 10, 2026 14:36
Mask /packmind/.nx in every container that bind-mounts the repo with a
new dev-nx named volume, mirroring the existing dev-dist/dev-tmp/
dev-node_modules pattern. Containers (Linux/Alpine) then share one
nx store among themselves while the host keeps its own .nx/ for local
nx runs, avoiding cross-OS cache/graph contamination.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01559xduNDjnWKxCfXXY4Qmf
The migrate/downgrade scripts' "clean nx state" step (docker compose
down + nx reset + rm -rf .nx) only clears the host store now. Add a
line to each that also drops the containers' dev-nx volume (filtered by
suffix since COMPOSE_PROJECT_NAME prefixes it). Document the dev-nx
isolation and its reset one-liner in CONTRIBUTING.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01559xduNDjnWKxCfXXY4Qmf
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR isolates Docker Nx state from the host checkout. The main changes are:

  • Adds a dedicated dev-nx Docker volume.
  • Mounts container Nx state at /packmind/.nx across development and build services.
  • Updates Node migration scripts to remove the container Nx volume.
  • Documents the Docker Nx reset command in CONTRIBUTING.md.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
CONTRIBUTING.md Documents the dedicated Docker Nx volume and the command to reset container Nx state.
docker-compose.yml Adds and mounts the dev-nx volume for the services that use Nx inside Docker.
migrate_node24.sh Adds guarded cleanup for Docker Nx volumes during the Node 24 migration.
downgrade_node22.sh Adds guarded cleanup for Docker Nx volumes during the Node 22 downgrade.

Reviews (3): Last reviewed commit: "fix(dev): make dev-nx volume cleanup por..." | Re-trigger Greptile

Comment thread migrate_node24.sh Outdated
Comment thread downgrade_node22.sh Outdated
Comment thread CONTRIBUTING.md Outdated
Address review feedback on the nx-volume cleanup:
- Drop `xargs -r`, which macOS/BSD xargs rejects ("illegal option -- r"),
  causing the removal to silently skip and leave the stale dev-nx volume.
  Capture the volume list into a variable and remove only when non-empty.
- Anchor the name filter to `dev-nx$` so it no longer also matches the
  sibling dev-nx-sock volume (Docker's name filter is a regex).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01559xduNDjnWKxCfXXY4Qmf
@cteyton

cteyton commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@greptile update your review

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants