diff --git a/src/base-ubuntu/.devcontainer/Dockerfile b/src/base-ubuntu/.devcontainer/Dockerfile index fe8aacbf4..a44bb2471 100644 --- a/src/base-ubuntu/.devcontainer/Dockerfile +++ b/src/base-ubuntu/.devcontainer/Dockerfile @@ -3,6 +3,15 @@ FROM buildpack-deps:${VARIANT}-curl LABEL dev.containers.features="common" +ARG VARIANT +RUN if [ "$VARIANT" = "noble" ]; then \ + if id "ubuntu" &>/dev/null; then \ + echo "Deleting user 'ubuntu' for $VARIANT" && userdel -f -r ubuntu || echo "Failed to delete ubuntu user for $VARIANT"; \ + else \ + echo "User 'ubuntu' does not exist for $VARIANT"; \ + fi; \ + fi + # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # && apt-get -y install --no-install-recommends diff --git a/src/base-ubuntu/.devcontainer/devcontainer.json b/src/base-ubuntu/.devcontainer/devcontainer.json index 4a4d21a71..d6b7e7040 100644 --- a/src/base-ubuntu/.devcontainer/devcontainer.json +++ b/src/base-ubuntu/.devcontainer/devcontainer.json @@ -7,6 +7,8 @@ "ghcr.io/devcontainers/features/common-utils:2": { "installZsh": "true", "username": "vscode", + "userUid": "1000", + "userGid": "1000", "upgradePackages": "true" }, "ghcr.io/devcontainers/features/git:1": { diff --git a/src/base-ubuntu/test-project/test.sh b/src/base-ubuntu/test-project/test.sh index bdb069077..545c48811 100755 --- a/src/base-ubuntu/test-project/test.sh +++ b/src/base-ubuntu/test-project/test.sh @@ -19,7 +19,21 @@ check "gitconfig-file-location" sh -c "ls /etc/gitconfig" check "gitconfig-contains-name" sh -c "cat /etc/gitconfig | grep 'name = devcontainers'" check "usr-local-etc-config-does-not-exist" test ! -f "/usr/local/etc/gitconfig" -check "uid" bash -c "id -u vscode | grep 1001" +check_ubuntu_user() { + if ! id -u ubuntu > /dev/null 2>&1; then + echo -e "✔️ User ubuntu does not exist." + else + echo -e "❌ User ubuntu exists." + exit 1; + fi +} + +if grep -q 'VERSION_CODENAME=noble' /etc/os-release; then + echo -e "\nThe base image is ubuntu:noble. Checking user Ubuntu.." + check "uid" "check_ubuntu_user" +else + echo -e "\nCannot check user Ubuntu. The base image is not ubuntu:noble." +fi # Report result reportResults