"vscode:/vscode.git/clone" did not exist on "e41e1715fdd48e567b08550f810ac74338cb9c26"
Dockerfile.local_dev 4.88 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# syntax=docker/dockerfile:1.10.0
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# This Dockerfile creates a local development environment for Dev Container plug-in use.
# It takes a BASE image (typically the dev target) and adds local-dev specific configurations
# including additional developer utilities and tools.
#
# Usage:
# - Dev Container IDE Extension: Use directly with VS Code/Cursor Dev Container extension
# - Command line: run.sh --image <local-dev-image> --mount-workspace ...
#   where the ubuntu user inside the container is mapped to your local user login

ARG DEV_BASE=""
FROM ${DEV_BASE} AS local-dev

17
18
19
20
# Switch to root for package installation (dev stage ends as dynamo user)
USER root
# Reset SHELL to non-login bash (dev stage uses login shell)
SHELL ["/bin/bash", "-c"]
21
22
23
24
25

# Update package lists and install developer utilities. Some of these may exist in the base image,
# but to ensure consistency across all dev images, we explicitly list all required dev tools here.
RUN apt-get update && apt-get install -y \
    # Development utilities
26
    curl wget git vim nano less \
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    # System utilities
    htop nvtop tmux screen \
    # Network utilities
    net-tools iproute2 iputils-ping \
    # Archive utilities
    zip unzip rsync \
    # Build tools
    build-essential cmake autoconf automake libtool \
    # Debug and analysis tools
    gdb valgrind strace ltrace \
    # Text processing
    jq yq grep sed \
    # File utilities
    tree fd-find ripgrep \
    # Shell utilities
42
43
44
    zsh fish bash-completion \
    # User management
    sudo gnupg2 gnupg1
45
46
47
48
49
50
51
52
53
54
55

# Install awk separately with fault tolerance
# awk is a virtual package with multiple implementations (gawk, mawk, original-awk).
# Separated because TensorRT-LLM builds failed on awk package conflicts.
# This prevents main package installation failures due to awk availability issues.
RUN (apt-get install -y gawk || \
     apt-get install -y mawk || \
     apt-get install -y original-awk || \
     echo "Warning: Could not install any awk implementation") && \
    (which awk && echo "awk successfully installed: $(which awk)" || echo "awk not available")

56
57
58
59
60
61
62
63

# Don't want dynamo to be editable, just change uid and gid.
ENV USERNAME=dynamo
ARG USER_UID
ARG USER_GID
ARG WORKSPACE_DIR=/workspace
ARG ARCH=amd64

64
65
66
67
68
69
# Add NVIDIA devtools repository and install development tools
RUN wget -qO - https://developer.download.nvidia.com/devtools/repos/ubuntu2404/${ARCH}/nvidia.pub | gpg --dearmor -o /etc/apt/keyrings/nvidia-devtools.gpg && \
    echo "deb [signed-by=/etc/apt/keyrings/nvidia-devtools.gpg] https://developer.download.nvidia.com/devtools/repos/ubuntu2404/${ARCH} /" | tee /etc/apt/sources.list.d/nvidia-devtools.list && \
    apt-get update && \
    apt-get install -y nsight-systems-2025.5.1

70
71
# https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user
# Configure user with sudo access for Dev Container workflows
72
RUN echo "$USERNAME ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/$USERNAME \
73
74
75
76
77
78
79
    && chmod 0440 /etc/sudoers.d/$USERNAME \
    && mkdir -p /home/$USERNAME \
    # Handle GID conflicts: if target GID exists and it's not our group, remove it
    && (getent group $USER_GID | grep -v "^$USERNAME:" && groupdel $(getent group $USER_GID | cut -d: -f1) || true) \
    # Create group if it doesn't exist, otherwise modify existing group
    && (getent group $USERNAME > /dev/null 2>&1 && groupmod -g $USER_GID $USERNAME || groupadd -g $USER_GID $USERNAME) \
    && usermod -u $USER_UID -g $USER_GID -G 0 $USERNAME \
80
    && chown $USERNAME:$USER_GID /home/$USERNAME \
81
82
83
    && chsh -s /bin/bash $USERNAME


84
85
86
87
88
89
90
91
92
93
94
# Clean up package lists at the end
RUN rm -rf /var/lib/apt/lists/*

# Set workspace directory variable
ENV WORKSPACE_DIR=${WORKSPACE_DIR}

# Development environment variables for the local-dev target
# Path configuration notes:
# - DYNAMO_HOME: Main project directory (workspace mount point)
# - CARGO_TARGET_DIR: Build artifacts in workspace/target for persistence
# - PATH: Includes cargo binaries for rust tool access
95
ENV HOME=/home/$USERNAME
96
97
ENV DYNAMO_HOME=${WORKSPACE_DIR}
ENV CARGO_TARGET_DIR=${WORKSPACE_DIR}/target
98
# NOTE: CARGO_HOME and RUSTUP_HOME are already inherited from dev stage (Dockerfile.sglang|trtllm|vllm)
99
100
ENV PATH=${CARGO_HOME}/bin:$PATH

101
# Switch to dynamo user (dev stage has umask 002, so files should already be group-writable)
102
103
104
105
106
107
USER $USERNAME
WORKDIR $HOME

# https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=$HOME/.commandhistory/.bash_history" \
    && mkdir -p $HOME/.commandhistory \
108
    && chmod g+w $HOME/.commandhistory \
109
110
111
    && touch $HOME/.commandhistory/.bash_history \
    && echo "$SNIPPET" >> "$HOME/.bashrc"

112
113
RUN mkdir -p /home/$USERNAME/.cache/ \
    && chmod g+w /home/$USERNAME/.cache/
114
115
116

ENTRYPOINT ["/opt/nvidia/nvidia_entrypoint.sh"]
CMD []