fix: configure Docker containers to run as current user

- Added user mapping (UID:GID) to Docker Compose services to prevent root-owned files
- Export current user's UID/GID in build.sh for Docker Compose
- Enhanced clean build to handle permission issues gracefully:
  * Try normal cleanup first
  * Fallback to container-based cleanup for root-owned files
  * Ultimate fallback to sudo if needed
- Added cleanup for all Docker volumes (build, source, kernel, target caches)

Fixes 'Permission denied' errors when cleaning output files created by Docker containers.
This commit is contained in:
2025-08-22 18:47:31 +02:00
parent 610963984f
commit 193662fb67
2 changed files with 19 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ services:
image: zero-os-alpine-builder:cached-${BUILDMODE:-debug}
container_name: zero-os-alpine-builder-cached
privileged: true
user: "${UID:-1000}:${GID:-1000}"
volumes:
# Mount source configs and scripts (read-only for cache efficiency)
- ../configs:/build/configs:ro
@@ -45,6 +46,7 @@ services:
image: zero-os-alpine-builder:legacy
container_name: zero-os-alpine-builder-legacy
privileged: true
user: "${UID:-1000}:${GID:-1000}"
volumes:
- ../configs:/build/configs:ro
- ../scripts:/build/scripts:ro