Skip to content

Commit 1aed545

Browse files
Update entrypoint.sh
Check `$DOCKER_USER` was defined before copying it to `$USER`.
1 parent fe9eaef commit 1aed545

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ci/release-image/entrypoint.sh

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ set -eu
55
# Otherwise the current container UID may not exist in the passwd database.
66
eval "$(fixuid -q)"
77

8-
USER="$DOCKER_USER"
8+
if [ "${DOCKER_USER-}" ]; then
9+
USER="$DOCKER_USER"
10+
if [ "$DOCKER_USER" != "$(whoami)" ]; then
11+
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd >/dev/null
12+
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
13+
# nor can we bind mount $HOME into a new home as that requires a privileged container.
14+
sudo usermod --login "$DOCKER_USER" coder
15+
sudo groupmod -n "$DOCKER_USER" coder
916

10-
if [ "${DOCKER_USER-}" ] && [ "$DOCKER_USER" != "$(whoami)" ]; then
11-
echo "$DOCKER_USER ALL=(ALL) NOPASSWD:ALL" | sudo tee -a /etc/sudoers.d/nopasswd >/dev/null
12-
# Unfortunately we cannot change $HOME as we cannot move any bind mounts
13-
# nor can we bind mount $HOME into a new home as that requires a privileged container.
14-
sudo usermod --login "$DOCKER_USER" coder
15-
sudo groupmod -n "$DOCKER_USER" coder
16-
17-
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
17+
sudo sed -i "/coder/d" /etc/sudoers.d/nopasswd
18+
fi
1819
fi
1920

2021
dumb-init /usr/bin/code-server "$@"

0 commit comments

Comments
 (0)