Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit ce7fd85

Browse files
authored
Fix UID/GID update for codespaces-linux smoke test
1 parent aa0e2d2 commit ce7fd85

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

.github/actions/smoke-test/action.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,25 @@ runs:
6969
fi
7070
7171
set -e
72-
73-
# Start container
74-
container_name="vscdc-test-container"
75-
docker run -d --name ${container_name} --rm --init --privileged -v "$(pwd)/containers/${{ inputs.definition }}:/workspace" ${{ inputs.image }} /bin/sh -c 'while sleep 1000; do :; done'
7672
7773
# Update UID/GID for user in container - Actions uses different UID/GID than container
7874
# which causes bind mounts to be read only and cause certain write tests to fail
7975
# The dev container CLI handles this automatically but we're not using it.
8076
local_uid=$(id -u)
8177
local_gid=$(id -g)
82-
echo "(*) Update container user UID/GID..."
83-
docker exec -u root ${container_name} /bin/sh -c "\
84-
groupmod -g ${local_gid} ${{ inputs.user }} \
85-
&& usermod -u ${local_uid} -g ${local_gid} ${{ inputs.user }}"
78+
echo "(*) Updating container user UID/GID..."
79+
echo -e "FROM ${{ inputs.image }}\n \
80+
RUN export sudo_cmd="" \
81+
&& if [ "$(id -u)" != "0" ]; then export sudo_cmd=sudo; fi \
82+
&& \${sudo_cmd} groupmod -g ${local_gid} ${{ inputs.user }} \
83+
&& \${sudo_cmd} usermod -u ${local_uid} -g ${local_gid} ${{ inputs.user }}" > uid.Dockerfile
84+
cat uid.Dockerfile
85+
docker buildx build --load -t ${{ inputs.image }}-uid -f uid.Dockerfile .
86+
87+
# Start container
88+
echo "(*) Starting container..."
89+
container_name="vscdc-test-container"
90+
docker run -d --name ${container_name} --rm --init --privileged -v "$(pwd)/containers/${{ inputs.definition }}:/workspace" ${{ inputs.image }}-uid /bin/sh -c 'while sleep 1000; do :; done'
8691
8792
# Fake out existence of extensions, VS Code Server
8893
echo "(*) Stubbing out extensions and VS Code Server..."

0 commit comments

Comments
 (0)