From d9fb802aa80859ec8b94d2ee675db1f18bb6554f Mon Sep 17 00:00:00 2001
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Sun, 10 Sep 2023 17:51:08 +0200
Subject: [PATCH] scripts: container.sh: keep UID/GID of host user in container

Fixes access to the build directory mounted into the container when UIDs
don't match.

For Docker, HOME is set in addition to get a more useful value than /
and for consistency with Podman.
---
 scripts/container.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/container.sh b/scripts/container.sh
index 072d2ec13..c1b850cfa 100755
--- a/scripts/container.sh
+++ b/scripts/container.sh
@@ -12,11 +12,11 @@ TAG="gluon:${BRANCH:-latest}"
 if [ "$(command -v podman)" ]
 then
 	podman build -t "${TAG}" contrib/docker
-	podman run -it --rm --userns=keep-id --volume="$(pwd):/gluon" "${TAG}"
+	podman run -it --rm -u "$(id -u):$(id -g)" --userns=keep-id --volume="$(pwd):/gluon" "${TAG}"
 elif [ "$(command -v docker)" ]
 then
 	docker build -t "${TAG}" contrib/docker
-	docker run -it --rm --volume="$(pwd):/gluon" "${TAG}"
+	docker run -it --rm -u "$(id -u):$(id -g)" --volume="$(pwd):/gluon" -e HOME=/gluon "${TAG}"
 else
 	1>&2 echo "Please install either podman or docker. Exiting" >/dev/null
 	exit 1
-- 
GitLab