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

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

What

Mount the cargo target cache at /cargo-target (outside the /build bind mount) in every cargo step of the pre-commit recipe, and point cargo at it with --env CARGO_TARGET_DIR=/cargo-target, instead of nesting the named volume at /build/target. The volume name (dev-vervain-apps-cargo-target) and the registry volume are unchanged.

Why (DEV-371)

Nesting a named volume at /build/target (inside the $PWD:/build bind mount) makes the Docker daemon materialize a root-owned target/ directory on the host, which then needs sudo to remove. Moving the cache mount outside the bind mount keeps the host tree clean while the cache still persists in the named volume.

The bun/tailwind (build-css) step already runs with --user $(id -u):(id -g), so its generated files are already host-owned and that step is left untouched.

Aligns with the governance Option A standard.

## What Mount the cargo target cache at `/cargo-target` (outside the `/build` bind mount) in every cargo step of the `pre-commit` recipe, and point cargo at it with `--env CARGO_TARGET_DIR=/cargo-target`, instead of nesting the named volume at `/build/target`. The volume name (`dev-vervain-apps-cargo-target`) and the registry volume are unchanged. ## Why (DEV-371) Nesting a named volume at `/build/target` (inside the `$PWD:/build` bind mount) makes the Docker daemon materialize a root-owned `target/` directory on the host, which then needs `sudo` to remove. Moving the cache mount outside the bind mount keeps the host tree clean while the cache still persists in the named volume. The bun/tailwind (`build-css`) step already runs with `--user $(id -u):(id -g)`, so its generated files are already host-owned and that step is left untouched. Aligns with the governance Option A standard.
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 8m26s
Create release / Create release from merged PR (pull_request) Has been skipped
1ead3760d6
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. The bun/tailwind step already runs as the host user, so its generated files are already host-owned. Aligns with the governance Option A standard.

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

#DEV-371
David merged commit 1dce76b80a into main 2026-06-19 09:59:39 +02:00
David deleted branch fix/dev-371-precommit-host-owned-target 2026-06-19 09:59:40 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
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
psa-systems/vervain-apps!40
No description provided.