diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8e70fab..8be0302 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,18 +1,34 @@ FROM python:3.14.5-slim-bookworm -ENV PLATFORMIO_CORE_DIR=/workspace/.platformio -ENV PATH="/root/.platformio/penv/bin:${PATH}" +ARG USERNAME=vscode +ARG USER_UID=1000 +ARG USER_GID=1000 + +ENV PLATFORMIO_CORE_DIR=/home/${USERNAME}/.platformio +ENV PATH="${PLATFORMIO_CORE_DIR}/penv/bin:${PATH}" RUN apt-get update && apt-get install -y --no-install-recommends \ git \ build-essential \ ca-certificates \ udev \ + openssh-client \ + sudo \ && rm -rf /var/lib/apt/lists/* RUN python -m pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir platformio +RUN groupadd --gid ${USER_GID} ${USERNAME} \ + && useradd --uid ${USER_UID} --gid ${USER_GID} --create-home --shell /bin/bash ${USERNAME} \ + && usermod --append --groups dialout ${USERNAME} \ + && mkdir -p /workspace ${PLATFORMIO_CORE_DIR} \ + && chown -R ${USERNAME}:${USERNAME} /workspace /home/${USERNAME} + +RUN echo "${USERNAME} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/${USERNAME} && \ + chmod 0440 /etc/sudoers.d/${USERNAME} + +USER ${USERNAME} WORKDIR /workspace CMD ["pio", "run"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bfea7fb..7f0c6df 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,6 +3,11 @@ "build": { "dockerfile": "./Dockerfile" }, + "remoteUser": "vscode", + "updateRemoteUserUID": true, + "mounts": [ + "source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,readonly" + ], "customizations": { "vscode": { "settings": {}, @@ -11,4 +16,4 @@ ] } } -} \ No newline at end of file +}