From 875ee8563e1609eaa92716b8a3f6f1db1b868c79 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 01:23:23 +0000 Subject: [PATCH 1/5] Initial plan From 73408134d53e97d6aabd88d2a3b4ec06c1b0a2f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 01:24:55 +0000 Subject: [PATCH 2/5] Fix Docker build: use locale-gen and remove userdel ubuntu step - Remove the 'userdel ubuntu' step that caused package setup warnings on modern ubuntu:latest images - Replace failing 'localedef -A /usr/share/locale/locale.alias' with the Ubuntu-standard locale-gen approach - Add LC_ALL=en_US.UTF-8 environment variable for full locale support" --- Dockerfile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7a636cc..dac8ee4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,13 +25,6 @@ ENV PS_VERSION=${PWSH_LTS_VERSION} ENV PS_MAJOR_VERSION=${PWSH_LTS_MAJOR_VERSION} ENV PS_INSTALL_FOLDER=/opt/microsoft/powershell/${PS_MAJOR_VERSION} -# If exists, remove 'ubuntu' user -RUN if id "ubuntu" &>/dev/null; then \ - echo "Deleting user 'ubuntu'" && userdel -f -r ubuntu || echo "Failed to delete ubuntu user"; \ - else \ - echo "User 'ubuntu' does not exist"; \ - fi; - # Install sudo and other necessary packages RUN apt-get update \ && apt-get -y install --no-install-recommends \ @@ -48,8 +41,11 @@ RUN apt-get update \ wget # Set US English and UTF-8 Locale -RUN localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 -ENV LANG=en_US.utf8 +RUN sed -i '/^# *en_US.UTF-8 UTF-8/s/^# *//' /etc/locale.gen \ + && locale-gen en_US.UTF-8 \ + && update-locale LANG=en_US.UTF-8 +ENV LANG=en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 # Defining non-root User ARG USERNAME=coder From 9ebf9599a1be3d9bcbca6c53dab519d75d9f85f2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 01:25:18 +0000 Subject: [PATCH 3/5] Combine ENV declarations into single instruction per Docker best practices --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index dac8ee4..7192933 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,8 +44,8 @@ RUN apt-get update \ RUN sed -i '/^# *en_US.UTF-8 UTF-8/s/^# *//' /etc/locale.gen \ && locale-gen en_US.UTF-8 \ && update-locale LANG=en_US.UTF-8 -ENV LANG=en_US.UTF-8 -ENV LC_ALL=en_US.UTF-8 +ENV LANG=en_US.UTF-8 \ + LC_ALL=en_US.UTF-8 # Defining non-root User ARG USERNAME=coder From 5e6c5330b7964a18c00612d1cb27d3645a9ee96d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 01:31:51 +0000 Subject: [PATCH 4/5] Handle default Ubuntu UID/GID in Docker build --- Dockerfile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7192933..c50a92a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,8 +54,26 @@ ARG USER_GID=$USER_UID # Set up User and grant sudo privileges # apt-get package: sudo -RUN groupadd --gid $USER_GID $USERNAME \ - && useradd --uid $USER_UID --gid $USER_GID --shell /bin/bash --create-home $USERNAME \ +RUN existing_group="$(getent group "$USER_GID" | cut -d: -f1 || true)" \ + && if [ -n "$existing_group" ]; then \ + [ "$existing_group" = "$USERNAME" ] || groupmod --new-name "$USERNAME" "$existing_group"; \ + else \ + groupadd --gid "$USER_GID" "$USERNAME"; \ + fi \ + && existing_user="$(getent passwd "$USER_UID" | cut -d: -f1 || true)" \ + && if [ -n "$existing_user" ]; then \ + if [ "$existing_user" = "$USERNAME" ]; then \ + usermod --gid "$USER_GID" --shell /bin/bash --home "/home/$USERNAME" "$USERNAME"; \ + else \ + usermod --login "$USERNAME" --home "/home/$USERNAME" --move-home --gid "$USER_GID" --shell /bin/bash "$existing_user"; \ + fi; \ + elif id "$USERNAME" &>/dev/null; then \ + usermod --uid "$USER_UID" --gid "$USER_GID" --shell /bin/bash --home "/home/$USERNAME" "$USERNAME"; \ + else \ + useradd --uid "$USER_UID" --gid "$USER_GID" --shell /bin/bash --create-home "$USERNAME"; \ + fi \ + && mkdir -p /home/$USERNAME \ + && chown $USER_UID:$USER_GID /home/$USERNAME \ && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ && chmod 0440 /etc/sudoers.d/$USERNAME WORKDIR /home/$USERNAME From 61fd2e87a015d9c61ac4775b648da3a2fcabf625 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 01:33:11 +0000 Subject: [PATCH 5/5] Harden Docker user setup for modern Ubuntu images --- Dockerfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index c50a92a..5b4eec6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,8 +44,7 @@ RUN apt-get update \ RUN sed -i '/^# *en_US.UTF-8 UTF-8/s/^# *//' /etc/locale.gen \ && locale-gen en_US.UTF-8 \ && update-locale LANG=en_US.UTF-8 -ENV LANG=en_US.UTF-8 \ - LC_ALL=en_US.UTF-8 +ENV LANG=en_US.UTF-8 # Defining non-root User ARG USERNAME=coder @@ -72,10 +71,10 @@ RUN existing_group="$(getent group "$USER_GID" | cut -d: -f1 || true)" \ else \ useradd --uid "$USER_UID" --gid "$USER_GID" --shell /bin/bash --create-home "$USERNAME"; \ fi \ - && mkdir -p /home/$USERNAME \ - && chown $USER_UID:$USER_GID /home/$USERNAME \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ - && chmod 0440 /etc/sudoers.d/$USERNAME + && mkdir -p "/home/$USERNAME" \ + && chown "$USER_UID":"$USER_GID" "/home/$USERNAME" \ + && echo "$USERNAME ALL=\(root\) NOPASSWD:ALL" > "/etc/sudoers.d/$USERNAME" \ + && chmod 0440 "/etc/sudoers.d/$USERNAME" WORKDIR /home/$USERNAME # Clean up