File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,8 +44,18 @@ RUN curl -fsSL https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/bi
4444ARG USERNAME=vscode
4545ARG USER_UID=1000
4646ARG USER_GID=$USER_UID
47- RUN if ! getent group $USER_GID >/dev/null; then groupadd --gid $USER_GID $USERNAME; fi && \
48- if ! getent passwd $USER_UID >/dev/null; then useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; fi && \
47+ RUN EXISTING_GROUP=$(getent group $USER_GID | cut -d: -f1 || echo "" ); \
48+ EXISTING_USER=$(getent passwd $USER_UID | cut -d: -f1 || echo "" ); \
49+ if [ -n "$EXISTING_GROUP" ] && [ "$EXISTING_GROUP" != "$USERNAME" ]; then \
50+ groupmod -n $USERNAME $EXISTING_GROUP; \
51+ elif [ -z "$EXISTING_GROUP" ]; then \
52+ groupadd --gid $USER_GID $USERNAME; \
53+ fi && \
54+ if [ -n "$EXISTING_USER" ] && [ "$EXISTING_USER" != "$USERNAME" ]; then \
55+ usermod -l $USERNAME -d /home/$USERNAME -m $EXISTING_USER; \
56+ elif [ -z "$EXISTING_USER" ]; then \
57+ useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; \
58+ fi && \
4959 echo $USERNAME ALL=\( root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
5060 chmod 0440 /etc/sudoers.d/$USERNAME
5161
You can’t perform that action at this time.
0 commit comments