From 141b1e33f2df80f62a54f24f210d9bade681bb14 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Tue, 30 Nov 2021 15:01:01 +0100 Subject: [PATCH] fix: handle user UID/GID --- docker/entrypoint.sh | 9 +++++++-- scripts/gx-teaching | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 34df587..9471843 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -9,7 +9,12 @@ echo "Arguments: $ARGS" EXT_UID=${EXT_UID:-999} EXT_GID=${EXT_GID:-999} -groupadd -g "$EXT_GID" appuser -useradd -r -u "$EXT_UID" -g appuser appuser +if ! grep "^[^:]*:[^:]*:$EXT_UID:" /etc/group ; then + groupadd -g "$EXT_GID" appuser +fi + +if ! grep "^[^:]*:[^:]*:$EXT_UID:" /etc/passwd ; then + useradd -r -u "$EXT_UID" -g appuser appuser +fi exec gosu appuser make "$@" diff --git a/scripts/gx-teaching b/scripts/gx-teaching index b78f778..cab7266 100755 --- a/scripts/gx-teaching +++ b/scripts/gx-teaching @@ -26,6 +26,8 @@ docker run -it \ -v "$BASEDIR/images:/app/images" \ -v "$BASEDIR/_build:/app/_build" \ -v "$BASEDIR/mkdocs.yml:/app/mkdocs.yml" \ + -e "EXT_UID=$(id -u)" \ + -e "EXT_GID=$(id -g)" \ $DOCKER_OPT_MARP_THEME \ -p 5200:5200 \ -p 5100:5100 \