use ubuntu user instead of root for uv docker images (#3491)

This commit is contained in:
Wing Lian
2026-03-12 20:41:13 -04:00
committed by GitHub
parent 819b157c7b
commit 79908b3c6e
4 changed files with 46 additions and 20 deletions

View File

@@ -17,11 +17,15 @@ ENV TORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST
ENV UV_TORCH_BACKEND="cu${CUDA}"
RUN apt-get update \
&& apt-get install -y wget git build-essential ninja-build git-lfs libaio-dev pkg-config curl && rm -rf /var/lib/apt/lists/* \
&& apt-get install -y wget git build-essential ninja-build git-lfs libaio-dev pkg-config curl sudo && rm -rf /var/lib/apt/lists/* \
&& git lfs install --skip-repo \
&& curl -LsSf https://astral.sh/uv/install.sh | sh
&& curl -LsSf https://astral.sh/uv/install.sh | env UV_INSTALL_DIR="/usr/local/bin" sh
ENV PATH="/root/.local/bin:${PATH}"
# Create ubuntu user with passwordless sudo
RUN useradd -m -s /bin/bash -u 1000 ubuntu 2>/dev/null; \
usermod -aG sudo ubuntu && \
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/ubuntu && \
chmod 0440 /etc/sudoers.d/ubuntu
RUN uv python install ${PYTHON_VERSION}
@@ -55,3 +59,5 @@ RUN PYTHON_CP="cp$(echo $PYTHON_VERSION | tr -d '.')" && \
wget -nv "https://github.com/mjun0812/flash-attention-prebuild-wheels/releases/download/${WHL_VERSION}/${WHL_FILE}" && \
uv pip install --no-cache-dir "${WHL_FILE}" && \
rm "${WHL_FILE}"
RUN chown -R ubuntu:ubuntu /workspace