Skip to content

Commit b6b3a76

Browse files
authored
revert: restore Dockerfile.vllm and build/run scripts to August 28 vers (#2892)
Signed-off-by: Keiven Chang <[email protected]> Co-authored-by: Keiven Chang <[email protected]>
1 parent 94f100b commit b6b3a76

File tree

3 files changed

+149
-108
lines changed

3 files changed

+149
-108
lines changed

container/Dockerfile.vllm

Lines changed: 122 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,55 @@ RUN --mount=type=bind,source=./container/launch_message.txt,target=/workspace/la
280280
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]
281281
CMD []
282282

283-
#######################################
284-
########## Local Development #######
285-
#######################################
283+
#######################################################################
284+
########## DEVELOPMENT TARGETS FEATURE MATRIX #########################
285+
#######################################################################
286+
# Feature │ local-dev Target │ dev Target
287+
# ─────────────────────┼─────────────────────┼─────────────────────
288+
# Purpose │ Dev Container │ Command-line with
289+
# │ plugin use only │ run.sh script
290+
# ─────────────────────┼─────────────────────┼─────────────────────
291+
# Default User │ ubuntu user │ root user
292+
# ─────────────────────┼─────────────────────┼─────────────────────
293+
# User Setup │ Full ubuntu user │ No user setup
294+
# │ with UID/GID │
295+
# │ mapping │
296+
# ─────────────────────┼─────────────────────┼─────────────────────
297+
# Permissions │ ubuntu user with │ Root-level
298+
# │ sudo privileges │ permissions
299+
# ─────────────────────┼─────────────────────┼─────────────────────
300+
# Home Directory │ /home/ubuntu │ /root
301+
# ─────────────────────┼─────────────────────┼─────────────────────
302+
# Working Directory │ /home/ubuntu/dynamo │ /workspace
303+
# ─────────────────────┼─────────────────────┼─────────────────────
304+
# Rust Toolchain │ User's home │ System locations
305+
# │ (~/.rustup, │ (/usr/local/rustup,
306+
# │ ~/.cargo) │ /usr/local/cargo)
307+
# ─────────────────────┼─────────────────────┼─────────────────────
308+
# Python Environment │ User-owned venv │ System location
309+
# │ │ (/opt/dynamo/venv)
310+
# ─────────────────────┼─────────────────────┼─────────────────────
311+
# File Permissions │ User-level with │ Root-level
312+
# │ proper ownership │ permissions
313+
# ─────────────────────┼─────────────────────┼─────────────────────
314+
# Compatibility │ MS Plug-in: Dev │ Backward compatibility
315+
# │ Container workflow │ with existing
316+
# │ │ workflows
286317
#
287-
# PURPOSE: Local development
288-
#
289-
# This stage adds development tools, utilities, and dependencies specifically
290-
# needed for:
291-
# - Local development and debugging
292-
# - vscode/cursor development
318+
# USAGE GUIDELINES:
319+
# • Use local-dev: VS Code/Cursor Dev Container plugin only
320+
# • Use dev: run.sh script for command-line development
321+
322+
323+
#######################################################################
324+
########## Development (Dev Container only) ###########################
325+
#######################################################################
293326
#
294-
# Use this stage when you need a full development environment with additional
295-
# tooling beyond the base runtime image.
327+
# This stage is for Dev Container plug-in use only.
328+
# It provides a local development environment with extra tools and dependencies
329+
# not present in the base runtime image.
296330

297-
FROM runtime AS dev
331+
FROM runtime AS local-dev
298332

299333
# Don't want ubuntu to be editable, just change uid and gid.
300334
ENV USERNAME=ubuntu
@@ -395,3 +429,79 @@ RUN mkdir -p /home/$USERNAME/.cache/
395429

396430
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]
397431
CMD []
432+
433+
434+
###########################################################
435+
########## Development (run.sh, runs as root user) ########
436+
###########################################################
437+
#
438+
# PURPOSE: Local development environment for use with run.sh (not Dev Container plug-in)
439+
#
440+
# This stage runs as root and provides:
441+
# - Development tools and utilities for local debugging
442+
# - Support for vscode/cursor development outside the Dev Container plug-in
443+
#
444+
# Use this stage if you need a full-featured development environment with extra tools,
445+
# but do not use it with the Dev Container plug-in.
446+
447+
FROM runtime AS dev
448+
449+
# Don't want ubuntu to be editable, just change uid and gid.
450+
ARG WORKSPACE_DIR=/workspace
451+
452+
# Install utilities as root
453+
RUN apt-get update -y && \
454+
apt-get install -y --no-install-recommends \
455+
# Install utilities
456+
nvtop \
457+
wget \
458+
tmux \
459+
vim \
460+
git \
461+
openssh-client \
462+
iproute2 \
463+
rsync \
464+
zip \
465+
unzip \
466+
htop \
467+
# Build Dependencies
468+
autoconf \
469+
automake \
470+
cmake \
471+
libtool \
472+
meson \
473+
net-tools \
474+
pybind11-dev \
475+
# Rust build dependencies
476+
clang \
477+
libclang-dev \
478+
protobuf-compiler && \
479+
rm -rf /var/lib/apt/lists/*
480+
481+
COPY --from=runtime /usr/local/bin /usr/local/bin
482+
483+
# Set workspace directory variable
484+
ENV WORKSPACE_DIR=${WORKSPACE_DIR} \
485+
DYNAMO_HOME=${WORKSPACE_DIR} \
486+
RUSTUP_HOME=/usr/local/rustup \
487+
CARGO_HOME=/usr/local/cargo \
488+
CARGO_TARGET_DIR=/workspace/target \
489+
VIRTUAL_ENV=/opt/dynamo/venv \
490+
PATH=/usr/local/cargo/bin:$PATH
491+
492+
COPY --from=dynamo_base /usr/local/rustup /usr/local/rustup
493+
COPY --from=dynamo_base /usr/local/cargo /usr/local/cargo
494+
495+
# This is a slow operation (~40s on my cpu)
496+
# Much better than chown -R $USERNAME:$USERNAME /opt/dynamo/venv (~10min on my cpu)
497+
COPY --from=runtime ${VIRTUAL_ENV} ${VIRTUAL_ENV}
498+
499+
# so we can use maturin develop
500+
RUN uv pip install maturin[patchelf]
501+
502+
# Make sure to sync this with the one specified on README.md.
503+
# This is a generic PYTHONPATH which works for all the frameworks, so some paths may not be relevant for this particular framework.
504+
ENV PYTHONPATH=${WORKSPACE_DIR}/components/metrics/src:${WORKSPACE_DIR}/components/frontend/src:${WORKSPACE_DIR}/components/planner/src:${WORKSPACE_DIR}/components/backends/mocker/src:${WORKSPACE_DIR}/components/backends/trtllm/src:${WORKSPACE_DIR}/components/backends/vllm/src:${WORKSPACE_DIR}/components/backends/sglang/src:${WORKSPACE_DIR}/components/backends/llama_cpp/src
505+
506+
ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]
507+
CMD []

container/build.sh

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ set -e
2424
TAG=
2525
RUN_PREFIX=
2626
PLATFORM=linux/amd64
27-
USER_UID=
28-
USER_GID=
2927

3028
# Get short commit hash
3129
commit_id=$(git rev-parse --short HEAD)
@@ -245,22 +243,6 @@ get_options() {
245243
missing_requirement "$1"
246244
fi
247245
;;
248-
--uid)
249-
if [ "$2" ]; then
250-
USER_UID="$2"
251-
shift
252-
else
253-
missing_requirement "$1"
254-
fi
255-
;;
256-
--gid)
257-
if [ "$2" ]; then
258-
USER_GID="$2"
259-
shift
260-
else
261-
missing_requirement "$1"
262-
fi
263-
;;
264246
--dry-run)
265247
RUN_PREFIX="echo"
266248
echo ""
@@ -437,8 +419,6 @@ show_help() {
437419
echo " [--cache-from cache location to start from]"
438420
echo " [--cache-to location where to cache the build output]"
439421
echo " [--tag tag for image]"
440-
echo " [--uid user ID for dev target (default: current user)]"
441-
echo " [--gid group ID for dev target (default: current group)]"
442422
echo " [--no-cache disable docker build cache]"
443423
echo " [--dry-run print docker commands without running]"
444424
echo " [--build-context name=path to add build context]"
@@ -463,14 +443,6 @@ error() {
463443

464444
get_options "$@"
465445

466-
# Validate UID/GID flags are only used with dev target
467-
if [ -n "$USER_UID" ] || [ -n "$USER_GID" ]; then
468-
if [[ "$TARGET" != "dev" ]]; then
469-
echo "⚠️ Warning: --uid and --gid flags are only effective with --target dev"
470-
echo " Current target: ${TARGET:-}"
471-
fi
472-
fi
473-
474446
# Automatically set ARCH and ARCH_ALT if PLATFORM is linux/arm64
475447
ARCH="amd64"
476448
if [[ "$PLATFORM" == *"linux/arm64"* ]]; then
@@ -492,15 +464,8 @@ fi
492464
# Add NIXL_REF as a build argument
493465
BUILD_ARGS+=" --build-arg NIXL_REF=${NIXL_REF} "
494466

495-
if [[ $TARGET == "dev" ]]; then
496-
# Use provided UID/GID or default to current user
497-
if [ -z "$USER_UID" ]; then
498-
USER_UID=$(id -u)
499-
fi
500-
if [ -z "$USER_GID" ]; then
501-
USER_GID=$(id -g)
502-
fi
503-
BUILD_ARGS+=" --build-arg USER_UID=$USER_UID --build-arg USER_GID=$USER_GID "
467+
if [[ $TARGET == "local-dev" ]]; then
468+
BUILD_ARGS+=" --build-arg USER_UID=$(id -u) --build-arg USER_GID=$(id -g) "
504469
fi
505470

506471
# BUILD DEV IMAGE

container/run.sh

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ DEFAULT_FRAMEWORK=VLLM
3131
SOURCE_DIR=$(dirname "$(readlink -f "$0")")
3232

3333
IMAGE=
34-
TARGET="dev"
3534
HF_CACHE=
3635
DEFAULT_HF_CACHE=${SOURCE_DIR}/.cache/huggingface
3736
GPUS="all"
3837
PRIVILEGED=
3938
VOLUME_MOUNTS=
4039
MOUNT_WORKSPACE=
41-
DEV_MODE=
4240
ENVIRONMENT_VARIABLES=
4341
REMAINING_ARGS=
4442
INTERACTIVE=
@@ -164,7 +162,6 @@ get_options() {
164162
--mount-workspace)
165163
MOUNT_WORKSPACE=TRUE
166164
;;
167-
168165
--use-nixl-gds)
169166
USE_NIXL_GDS=TRUE
170167
;;
@@ -230,11 +227,32 @@ get_options() {
230227
ENTRYPOINT_STRING="--entrypoint ${ENTRYPOINT}"
231228
fi
232229

230+
if [ -n "$MOUNT_WORKSPACE" ]; then
231+
VOLUME_MOUNTS+=" -v ${SOURCE_DIR}/..:/workspace "
232+
VOLUME_MOUNTS+=" -v /tmp:/tmp "
233+
VOLUME_MOUNTS+=" -v /mnt/:/mnt "
234+
235+
if [ -z "$HF_CACHE" ]; then
236+
HF_CACHE=$DEFAULT_HF_CACHE
237+
fi
238+
239+
if [ -z "${PRIVILEGED}" ]; then
240+
PRIVILEGED="TRUE"
241+
fi
242+
243+
ENVIRONMENT_VARIABLES+=" -e HF_TOKEN"
244+
245+
INTERACTIVE=" -it "
246+
fi
247+
233248
if [[ ${HF_CACHE^^} == "NONE" ]]; then
234249
HF_CACHE=
235250
fi
236251

237-
# HF_CACHE mounting will be handled in workspace section
252+
if [ -n "$HF_CACHE" ]; then
253+
mkdir -p "$HF_CACHE"
254+
VOLUME_MOUNTS+=" -v $HF_CACHE:/root/.cache/huggingface"
255+
fi
238256

239257
if [ -z "${PRIVILEGED}" ]; then
240258
PRIVILEGED="FALSE"
@@ -244,9 +262,9 @@ get_options() {
244262
RM="TRUE"
245263
fi
246264

247-
# Initialize PRIVILEGED_STRING
248-
PRIVILEGED_STRING=""
249-
if [[ ${PRIVILEGED^^} != "FALSE" ]]; then
265+
if [[ ${PRIVILEGED^^} == "FALSE" ]]; then
266+
PRIVILEGED_STRING=""
267+
else
250268
PRIVILEGED_STRING="--privileged"
251269
fi
252270

@@ -273,23 +291,13 @@ get_options() {
273291
RUNTIME=""
274292
fi
275293

276-
# Auto-enable DEV_MODE for vllm dev images
277-
# TODO(keivenc): Currently only Dockerfile.vllm has proper permissions to run as ubuntu user.
278-
# Other Dockerfiles (trtllm, sglang, etc.) still require root access.
279-
if [[ "$IMAGE" == *"-vllm-dev" ]]; then
280-
DEV_MODE=TRUE
281-
MOUNT_WORKSPACE=TRUE
282-
# Interactive mode is implied when MOUNT_WORKSPACE is TRUE
283-
fi
284-
285294
REMAINING_ARGS=("$@")
286295
}
287296

288297
show_help() {
289298
echo "usage: run.sh"
290299
echo " [--image image]"
291300
echo " [--framework framework one of ${!FRAMEWORKS[*]}]"
292-
echo " [--target target stage to use, default is 'dev']"
293301
echo " [--name name for launched container, default NONE]"
294302
echo " [--privileged whether to launch in privileged mode, default FALSE unless mounting workspace]"
295303
echo " [--dry-run print docker commands without running]"
@@ -318,48 +326,6 @@ error() {
318326

319327
get_options "$@"
320328

321-
# Process workspace mounting after auto-detection
322-
if [ -n "$MOUNT_WORKSPACE" ]; then
323-
HOME_PATH="/home/ubuntu"
324-
325-
# Common workspace setup
326-
VOLUME_MOUNTS+=" -v $(dirname "${SOURCE_DIR}"):/workspace "
327-
VOLUME_MOUNTS+=" -v /tmp:/tmp "
328-
VOLUME_MOUNTS+=" -v /mnt/:/mnt "
329-
WORKDIR=/workspace
330-
INTERACTIVE=" -it "
331-
332-
# Set default HF_CACHE if not specified
333-
if [ -z "$HF_CACHE" ]; then
334-
HF_CACHE=$DEFAULT_HF_CACHE
335-
fi
336-
337-
# Environment variables for all workspace modes
338-
ENVIRONMENT_VARIABLES+=" -e HF_TOKEN"
339-
ENVIRONMENT_VARIABLES+=" -e GITHUB_TOKEN"
340-
ENVIRONMENT_VARIABLES+=" -e HOME=$HOME_PATH"
341-
342-
# Mount HF_CACHE to user's home cache directory
343-
if [ -n "$HF_CACHE" ]; then
344-
mkdir -p "$HF_CACHE"
345-
VOLUME_MOUNTS+=" -v $HF_CACHE:$HOME_PATH/.cache/huggingface"
346-
fi
347-
348-
if [ -n "$DEV_MODE" ]; then
349-
# Dev Container-specific setup - the Dockerfile handles UID/GID mapping via build args
350-
# This currently only works with Dockerfile.vllm which has proper ubuntu user setup.
351-
echo "Dev Container mode enabled - using ubuntu user with host UID/GID"
352-
# Use ubuntu user (with correct UID/GID baked into image)
353-
PRIVILEGED_STRING+=" --user ubuntu"
354-
else
355-
# Standard workspace mode - enable privileged mode
356-
# TODO(keivenc): Security risk, remove soon. Dockerfiles (trtllm, sglang) still need to run as root.
357-
if [ -z "${PRIVILEGED}" ]; then
358-
PRIVILEGED_STRING="--privileged"
359-
fi
360-
fi
361-
fi
362-
363329
# RUN the image
364330
if [ -z "$RUN_PREFIX" ]; then
365331
set -x

0 commit comments

Comments
 (0)