Adding sudo + ssh

This commit is contained in:
Simon Milvert 2026-06-11 07:37:19 +00:00
parent 7bf2947076
commit 4dba15088a
2 changed files with 24 additions and 3 deletions

View File

@ -1,18 +1,34 @@
FROM python:3.14.5-slim-bookworm FROM python:3.14.5-slim-bookworm
ENV PLATFORMIO_CORE_DIR=/workspace/.platformio ARG USERNAME=vscode
ENV PATH="/root/.platformio/penv/bin:${PATH}" 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 \ RUN apt-get update && apt-get install -y --no-install-recommends \
git \ git \
build-essential \ build-essential \
ca-certificates \ ca-certificates \
udev \ udev \
openssh-client \
sudo \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
RUN python -m pip install --no-cache-dir --upgrade pip \ RUN python -m pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir platformio && 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 WORKDIR /workspace
CMD ["pio", "run"] CMD ["pio", "run"]

View File

@ -3,6 +3,11 @@
"build": { "build": {
"dockerfile": "./Dockerfile" "dockerfile": "./Dockerfile"
}, },
"remoteUser": "vscode",
"updateRemoteUserUID": true,
"mounts": [
"source=${localEnv:HOME}/.ssh,target=/home/vscode/.ssh,type=bind,readonly"
],
"customizations": { "customizations": {
"vscode": { "vscode": {
"settings": {}, "settings": {},