mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-05-12 01:10:22 +00:00
Updated Dev Container (#591)
* Added more features in Dev Container * Made it runnable on AMD platforms --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,13 +1,55 @@
|
||||
ARG BASE_IMAGE
|
||||
FROM ${BASE_IMAGE}
|
||||
ARG USERNAME=mscclpp
|
||||
ARG USERNAME=devuser
|
||||
ARG USER_UID=1000
|
||||
ARG USER_GID=$USER_UID
|
||||
ARG SSH_PORT=22345
|
||||
|
||||
# Create the user
|
||||
RUN groupadd --gid $USER_GID $USERNAME && \
|
||||
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME && \
|
||||
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
|
||||
chmod 0440 /etc/sudoers.d/$USERNAME
|
||||
# Create or modify the user
|
||||
RUN if getent group $USER_GID > /dev/null; then \
|
||||
EXISTING_GROUP=$(getent group $USER_GID | cut -d: -f1); \
|
||||
if [ "$EXISTING_GROUP" != "$USERNAME" ]; then \
|
||||
groupmod -n $USERNAME $EXISTING_GROUP; \
|
||||
fi; \
|
||||
else \
|
||||
groupadd --gid $USER_GID $USERNAME; \
|
||||
fi && \
|
||||
if id -u $USER_UID > /dev/null 2>&1; then \
|
||||
EXISTING_USER=$(getent passwd $USER_UID | cut -d: -f1); \
|
||||
if [ "$EXISTING_USER" != "$USERNAME" ]; then \
|
||||
usermod -l $USERNAME -d /home/$USERNAME -m $EXISTING_USER; \
|
||||
fi; \
|
||||
else \
|
||||
useradd --uid $USER_UID --gid $USER_GID -m $USERNAME; \
|
||||
fi && \
|
||||
usermod -g $USERNAME $USERNAME && \
|
||||
echo "$USERNAME ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
RUN rm -rf /etc/apt/sources.list.d/cuda-* && \
|
||||
apt-get update && \
|
||||
apt install -y --no-install-recommends \
|
||||
clang-format \
|
||||
openssh-server \
|
||||
gdb \
|
||||
doxygen \
|
||||
graphviz \
|
||||
&& \
|
||||
apt-get autoremove -y && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/*
|
||||
|
||||
RUN python3 -m pip install --no-cache-dir \
|
||||
black \
|
||||
pytest \
|
||||
breathe \
|
||||
sphinx_rtd_theme \
|
||||
myst_parser \
|
||||
sphinxcontrib.mermaid
|
||||
|
||||
RUN sed -i "s/^Port 22/Port ${SSH_PORT}/" /etc/ssh/sshd_config && \
|
||||
mkdir -p /home/$USERNAME/.ssh && \
|
||||
ssh-keygen -t rsa -f /home/$USERNAME/.ssh/id_rsa -N "" -q && \
|
||||
cat /home/$USERNAME/.ssh/id_rsa.pub >> /home/$USERNAME/.ssh/authorized_keys && \
|
||||
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
|
||||
|
||||
USER $USERNAME
|
||||
|
||||
Reference in New Issue
Block a user