fix(hooks): mount cargo target outside bind mount via CARGO_TARGET_DIR #18

Merged
David merged 1 commit from fix/dev-371-precommit-host-owned-target into main 2026-06-19 09:49:40 +02:00
Owner

What

Change the pre-commit justfile recipe to mount the dev-forgejo-mcp-cargo-target named volume at /cargo-target (outside the /build bind mount) and point cargo at it with --env CARGO_TARGET_DIR=/cargo-target, instead of nesting it at /build/target. The volume name is unchanged, so the build cache still persists.

Why (DEV-371)

Mounting the named volume at /build/target nests it inside the /build host bind mount. The Docker daemon then materializes a root-owned target/ directory on the host, which requires sudo to remove and leaves stray files after running just pre-commit. Moving the mount path off the bind mount stops the daemon from creating any host-side target/.

Governance note

Applies the governance Option A standard: mount the cargo target cache outside the bind mount and select it via CARGO_TARGET_DIR.

## What Change the `pre-commit` justfile recipe to mount the `dev-forgejo-mcp-cargo-target` named volume at `/cargo-target` (outside the `/build` bind mount) and point cargo at it with `--env CARGO_TARGET_DIR=/cargo-target`, instead of nesting it at `/build/target`. The volume name is unchanged, so the build cache still persists. ## Why (DEV-371) Mounting the named volume at `/build/target` nests it inside the `/build` host bind mount. The Docker daemon then materializes a root-owned `target/` directory on the host, which requires sudo to remove and leaves stray files after running `just pre-commit`. Moving the mount path off the bind mount stops the daemon from creating any host-side `target/`. ## Governance note Applies the governance Option A standard: mount the cargo target cache outside the bind mount and select it via `CARGO_TARGET_DIR`.
fix(hooks): mount cargo target outside bind mount via CARGO_TARGET_DIR
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 1m3s
Create release / Create release from merged PR (pull_request) Has been skipped
4cc2ff5d29
Mount the cargo target cache at /cargo-target (outside the /build bind mount) and point cargo at it with CARGO_TARGET_DIR, instead of nesting the named volume at /build/target, which makes the Docker daemon create a root-owned target/ on the host that needs sudo to remove. The cache still persists in the named volume; only its mount path moves off the bind mount. Aligns with the governance Option A standard.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

#DEV-371
David merged commit 93690d2cf3 into main 2026-06-19 09:49:40 +02:00
David deleted branch fix/dev-371-precommit-host-owned-target 2026-06-19 09:49:40 +02:00
Commenting is not possible because the repository is archived.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pandoras-box/forgejo-mcp!18
No description provided.