From b77493f1643d9afe561971e544ffbc7cf5d98ecf Mon Sep 17 00:00:00 2001 From: Nick Spinale Date: Mon, 22 Apr 2024 06:26:04 +0000 Subject: [PATCH] docker: Don't add user or group if they already exist Signed-off-by: Nick Spinale --- docker/Dockerfile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5a87ec4..234b15f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -67,10 +67,17 @@ RUN set -eux; \ ARG UID ARG GID -RUN groupadd -f -g $GID x && useradd -u $UID -g $GID -G sudo -m -p x x +RUN set -eux; \ + if ! getent group $GID; then \ + groupadd -g $GID x; \ + fi; \ + if ! getent passwd $UID; then \ + useradd -u $UID -g $GID -G sudo -m -p x x; \ + fi; + RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers # for convenience -USER x +USER $UID:$GID # This time, for the non-root user RUN curl -sSf https://sh.rustup.rs | \