Skip to content

Commit

Permalink
change the devcontainer remote user to ubuntu
Browse files Browse the repository at this point in the history
The new ubuntu 24.x image includes a user named `ubuntu` that has a UID
of 1000. I tried to create a vscode user with UID of 1001 but it didn't
work. I tried several things but eventually I gave up and embraced the
`ubuntu` user.

I had to delete the .nox directory to get pre-commit to work again. I
also needed to manually select the python interpreter in vscode.
  • Loading branch information
shadycuz committed May 1, 2024
1 parent 43a9b04 commit 3925c53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
FROM ubuntu:24.04

ARG USERNAME=vscode
ARG USERNAME=ubuntu
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Ensure apt is in non-interactive to avoid prompts
ENV DEBIAN_FRONTEND=noninteractive

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
RUN apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
Expand Down Expand Up @@ -43,12 +39,12 @@ SHELL ["/bin/bash","--login", "-c"]

# Stuff needed to make pyenv work correctly since the login shell
# above doesnt seem to run bachrc
ENV PYENV_ROOT="/home/vscode/.pyenv"
ENV PYENV_ROOT="/home/ubuntu/.pyenv"
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH


# Install the required python versions (this takes a bit usually) so we do lots of cacheing
RUN --mount=type=cache,target=/home/vscode/.pyenv/cache,uid=1000 \
RUN --mount=type=cache,target=/home/ubuntu/.pyenv/cache,uid=1000 \
pyenv install -s 3.8.18 && \
pyenv install -s 3.9.18 && \
pyenv install -s 3.10.13 && \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
"postCreateCommand": "poetry install && pre-commit install",
// "postStartCommand": "",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"remoteUser": "ubuntu"
}

0 comments on commit 3925c53

Please sign in to comment.