From 3d0c5e95f26f685799ecee370ae43a20e96190b9 Mon Sep 17 00:00:00 2001 From: softjapan Date: Thu, 2 Jan 2025 12:38:32 +0900 Subject: [PATCH] Refactor User and Group Creation in Dockerfile for Improved Efficiency and Simplicity refactors the user and group creation process in the Dockerfile to address inefficiencies, reduce redundancy, and enhance simplicity. --- Dockerfile | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4325f036734..6510c68b4df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,17 +43,12 @@ RUN curl -LSs "https://github.com/scottchiefbaker/dool/archive/${DOOL_VERSION}.t tar --strip-components=1 -xz && \ ./install.py -# Check if the group ID is already created +# create group and user ARG GROUP_ID -RUN if ! getent group "$GROUP_ID"; then \ - addgroup --gid "$GROUP_ID" user; \ - fi - -# Check if the user ID is already created ARG USER_ID -RUN if ! getent passwd "$USER_ID"; then \ - adduser --disabled-password --gecos '' --gid "$GROUP_ID" --uid "$USER_ID" user; \ - fi + +RUN groupadd -g "$GROUP_ID" user || true && \ + useradd -m -u "$USER_ID" -g "$GROUP_ID" -s /bin/bash user || true ENV FWROOT=/FrameworkBenchmarks USER_ID="$USER_ID" ENV PYTHONPATH="$FWROOT"