From 5186f93e3b629ad29dc9b4b58c2144cdc95b13bc Mon Sep 17 00:00:00 2001 From: vsoch Date: Sun, 26 Feb 2023 16:15:18 -0700 Subject: [PATCH] docker dev environment fix permissions Problem: permissions are written as root in the current devcontainer Solution: run them as the vscode user with uid/gid 1000 Signed-off-by: vsoch --- .devcontainer/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 15d583cc..cd3f4299 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,13 @@ FROM fluxrm/flux-sched:focal +# Match the default user id for a single system so we aren't root +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=1000 +ENV USERNAME=${USERNAME} +ENV USER_UID=${USER_UID} +ENV USER_GID=${USER_GID} + LABEL maintainer="Vanessasaurus <@vsoch>" # Pip not provided in this version @@ -17,5 +25,11 @@ RUN python3 -m pip install IPython && \ # For developer convenience ln -s /usr/bin/python3 /usr/bin/python +# Add the group and user that match our ids +RUN groupadd -g ${USER_GID} ${USERNAME} && \ + adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \ + echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers +USER $USERNAME + ENV PATH=/env/bin:${PATH} WORKDIR /workspace/flux-docs