Skip to content

fix(tools): chown bind-mounted build outputs back to host user#159

Draft
ottobolyos wants to merge 1 commit into
TrakHound:masterfrom
ottobolyos:fix/docker-obj-ownership
Draft

fix(tools): chown bind-mounted build outputs back to host user#159
ottobolyos wants to merge 1 commit into
TrakHound:masterfrom
ottobolyos:fix/docker-obj-ownership

Conversation

@ottobolyos
Copy link
Copy Markdown
Contributor

Summary

When tools/dotnet.sh --docker (and transitively tools/test.sh --docker) is used, bin/, obj/, TestResults/, and CoverageReport/ directories under the bind-mounted repo end up root-owned on the host because the SDK image runs dotnet as root. This blocks subsequent native dotnet invocations, rm -rf cleanups, and git clean from removing those outputs without sudo.

  • Wrap the in-container dotnet call in a thin bash entrypoint that, on exit, walks the bind-mounted /src tree and chowns the build-output directories back to the host user's UID:GID (passed in via HOST_UID / HOST_GID environment variables).
  • The chown runs unconditionally on exit so a failing dotnet call still hands the build outputs back to the user; the original dotnet exit code is preserved.
  • Named volumes that back the NuGet package cache and the dotnet-tools store stay root-owned inside the container; they are not visible to the host and do not interfere with host-side workflows.

The SDK image runs `dotnet` as root by default. Files written to the
bind-mounted repo - bin/, obj/, TestResults/, CoverageReport/ - end up
root-owned on the host, blocking the user's subsequent native dotnet
invocations, `rm -rf` cleanups, and `git clean` from removing them.

Wrap the in-container dotnet call in a thin bash entrypoint that, on
exit, walks the bind-mounted /src tree and chowns those output
directories back to the host user's UID:GID (passed in via
HOST_UID / HOST_GID environment variables). The named volumes that
back the NuGet package cache and the dotnet-tools store stay
root-owned inside the container since they are not visible to the
host and do not interfere with host-side workflows.

The chown runs unconditionally on exit so a failing dotnet call still
hands the build outputs back to the user; the original dotnet exit
code is preserved.
@ottobolyos ottobolyos marked this pull request as ready for review May 13, 2026 21:10
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