@@ -23,20 +23,17 @@ ARG GCC_SUFFIX
2323# Run as root for system-level installs
2424USER root
2525
26- # Create non-root user (GID 0 follows OpenShift convention for random UID support)
27- RUN useradd -u 1000 -g 0 -m -d /home/devuser -s /bin/bash devuser
28-
29- # Add google cloud cli repo
30- RUN printf "[google-cloud-cli]\n \
26+ # Layer 1: User creation, system packages, gh CLI, gcc, ssh, nix config
27+ RUN useradd -u 1000 -g 0 -m -d /home/devuser -s /bin/bash devuser \
28+ && printf "[google-cloud-cli]\n \
3129name=Google Cloud CLI\n \
3230baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-x86_64\n \
3331enabled=1\n \
3432gpgcheck=1\n \
3533repo_gpgcheck=0\n \
36- gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\n " > /etc/yum.repos.d/google-cloud-sdk.repo
37-
38- RUN dnf upgrade --refresh -y && \
39- dnf install -y \
34+ gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg\n " > /etc/yum.repos.d/google-cloud-sdk.repo \
35+ && dnf upgrade --refresh -y \
36+ && dnf install -y \
4037 python3 \
4138 python3-devel \
4239 python3-pip \
@@ -62,54 +59,37 @@ RUN dnf upgrade --refresh -y && \
6259 htop \
6360 nix \
6461 nodejs \
65- sudo && \
66- dnf clean all
67-
68- # Enable Nix flakes
69- RUN mkdir -p /home/devuser/.config/nix \
70- && echo 'experimental-features = nix-command flakes' > /home/devuser/.config/nix/nix.conf
71-
72- RUN dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo && dnf install gh --repo gh-cli -y && dnf clean all
73-
74- RUN mkdir -p -m 0700 /home/devuser/.ssh && ssh-keyscan github.com >> /home/devuser/.ssh/known_hosts
75-
76- # Install gcc c++ (may change for new versions). Also installs gcc.
77- # CUDA 12.x requires gcc-13; CUDA 13.x supports the system compiler.
78- RUN if [ -n "${GCC_SUFFIX}" ]; then \
79- dnf install -y "gcc$(echo ${GCC_SUFFIX} | tr -d '-')-c++" \
80- && alternatives --install /usr/bin/gcc gcc "/usr/bin/gcc${GCC_SUFFIX}" 100 \
81- && alternatives --install /usr/bin/g++ g++ "/usr/bin/g++${GCC_SUFFIX}" 100; \
82- else \
83- dnf install -y gcc-c++; \
84- fi \
85- && dnf clean all
62+ sudo \
63+ && dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo \
64+ && dnf install gh --repo gh-cli -y \
65+ && if [ -n "${GCC_SUFFIX}" ]; then \
66+ dnf install -y "gcc$(echo ${GCC_SUFFIX} | tr -d '-')-c++" \
67+ && alternatives --install /usr/bin/gcc gcc "/usr/bin/gcc${GCC_SUFFIX}" 100 \
68+ && alternatives --install /usr/bin/g++ g++ "/usr/bin/g++${GCC_SUFFIX}" 100; \
69+ else \
70+ dnf install -y gcc-c++; \
71+ fi \
72+ && dnf clean all \
73+ && mkdir -p /home/devuser/.config/nix \
74+ && echo 'experimental-features = nix-command flakes' > /home/devuser/.config/nix/nix.conf \
75+ && mkdir -p -m 0700 /home/devuser/.ssh \
76+ && ssh-keyscan github.com >> /home/devuser/.ssh/known_hosts
8677
87- # Install CUDA Toolkit via network repo
78+ # Layer 2: CUDA toolkit + cuDNN
8879RUN CUDA_PKG_VERSION=$(echo ${CUDA_VERSION} | tr '.' '-' ) \
8980 && dnf config-manager addrepo --from-repofile=https://developer.download.nvidia.com/compute/cuda/repos/fedora${FEDORA_VERSION}/x86_64/cuda-fedora${FEDORA_VERSION}.repo \
9081 && dnf -y install cuda-toolkit-${CUDA_PKG_VERSION} \
91- && dnf clean all
92-
93- # install g++ compiler that is compatiable with nvcc
94- # RUN dnf install gcc13-c++
95- # RUN export NVCC_CCBIN='g++-13'
96-
97- # #update path to include nvcc
98- # RUN export PATH=${PATH}:/usr/local/cuda-12.9/bin
99-
100- # Install cuDNN (single layer)
101- RUN mkdir ./cudnn \
102- && cd cudnn \
82+ && dnf clean all \
83+ && mkdir /tmp/cudnn \
84+ && cd /tmp/cudnn \
10385 && wget https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${CUDNN_VERSION}_${CUDNN_CUDA_SUFFIX}-archive.tar.xz \
10486 && tar xvf cudnn-linux-x86_64-${CUDNN_VERSION}_${CUDNN_CUDA_SUFFIX}-archive.tar.xz \
10587 && mv ./cudnn-linux-x86_64-${CUDNN_VERSION}_${CUDNN_CUDA_SUFFIX}-archive/include/* /usr/local/cuda/include \
10688 && mv ./cudnn-linux-x86_64-${CUDNN_VERSION}_${CUDNN_CUDA_SUFFIX}-archive/lib/* /usr/local/cuda/lib64 \
107- && cd / && rm -rf ./cudnn
89+ && cd / && rm -rf /tmp/cudnn \
90+ && chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
10891
109- # Update file permissions
110- RUN chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
111-
112- # Install miniconda to /home/devuser/miniconda (single layer)
92+ # Layer 3: Conda + Python
11393ARG PY_VER
11494ENV HOME=/home/devuser
11595RUN curl -fLO --retry 3 --retry-delay 5 "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-${OS_TYPE}.sh" \
@@ -121,35 +101,31 @@ RUN curl -fLO --retry 3 --retry-delay 5 "https://github.com/conda-forge/miniforg
121101 && /home/devuser/miniconda/bin/conda clean -afy
122102ENV PATH=/home/devuser/miniconda/bin:${PATH}
123103
124- # Install torch requirements.
104+ # Layer 4: PyTorch requirements + triton
125105ARG PYTORCH_RAW=https://raw.githubusercontent.com/pytorch/pytorch/refs/heads/main
126-
127- RUN mkdir /build_pytorch
128- ADD ${PYTORCH_RAW}/requirements.txt /build_pytorch/requirements.txt
129- ADD ${PYTORCH_RAW}/requirements-build.txt /build_pytorch/requirements-build.txt
130- ADD ${PYTORCH_RAW}/Makefile /build_pytorch/Makefile
131- RUN /home/devuser/miniconda/bin/pip install --no-cache-dir -r /build_pytorch/requirements.txt mkl-static mkl-include
132-
133- # Install triton.
134- RUN mkdir /build_pytorch/scripts
135- ADD ${PYTORCH_RAW}/scripts/install_triton_wheel.sh /build_pytorch/scripts/install_triton_wheel.sh
136- RUN chmod +x /build_pytorch/scripts/install_triton_wheel.sh && mkdir -p /build_pytorch/.ci/docker/
137- ADD ${PYTORCH_RAW}/.ci/docker/triton_version.txt /build_pytorch/.ci/docker/triton_version.txt
138- ADD ${PYTORCH_RAW}/.ci/docker/triton_xpu_version.txt /build_pytorch/.ci/docker/triton_xpu_version.txt
139- RUN mkdir -p /build_pytorch/.ci/docker/ci_commit_pins/
140- ADD ${PYTORCH_RAW}/.ci/docker/ci_commit_pins/triton.txt /build_pytorch/.ci/docker/ci_commit_pins/triton.txt
141- ADD ${PYTORCH_RAW}/.ci/docker/ci_commit_pins/triton-xpu.txt /build_pytorch/.ci/docker/ci_commit_pins/triton-xpu.txt
142- RUN cd /build_pytorch && make triton && rm -rf /build_pytorch
143-
144- # Install Ray
106+ RUN mkdir -p /build_pytorch/scripts /build_pytorch/.ci/docker/ci_commit_pins \
107+ && curl -fL -o /build_pytorch/requirements.txt ${PYTORCH_RAW}/requirements.txt \
108+ && curl -fL -o /build_pytorch/requirements-build.txt ${PYTORCH_RAW}/requirements-build.txt \
109+ && curl -fL -o /build_pytorch/Makefile ${PYTORCH_RAW}/Makefile \
110+ && curl -fL -o /build_pytorch/scripts/install_triton_wheel.sh ${PYTORCH_RAW}/scripts/install_triton_wheel.sh \
111+ && curl -fL -o /build_pytorch/.ci/docker/triton_version.txt ${PYTORCH_RAW}/.ci/docker/triton_version.txt \
112+ && curl -fL -o /build_pytorch/.ci/docker/triton_xpu_version.txt ${PYTORCH_RAW}/.ci/docker/triton_xpu_version.txt \
113+ && curl -fL -o /build_pytorch/.ci/docker/ci_commit_pins/triton.txt ${PYTORCH_RAW}/.ci/docker/ci_commit_pins/triton.txt \
114+ && curl -fL -o /build_pytorch/.ci/docker/ci_commit_pins/triton-xpu.txt ${PYTORCH_RAW}/.ci/docker/ci_commit_pins/triton-xpu.txt \
115+ && chmod +x /build_pytorch/scripts/install_triton_wheel.sh \
116+ && /home/devuser/miniconda/bin/pip install --no-cache-dir -r /build_pytorch/requirements.txt mkl-static mkl-include \
117+ && cd /build_pytorch && make triton \
118+ && (/home/devuser/miniconda/bin/pip uninstall torch ray -y 2>/dev/null || true) \
119+ && rm -rf /build_pytorch
120+
121+ # Layer 5: Ray requirements + bazel
145122ARG RAY_RAW=https://raw.githubusercontent.com/ray-project/ray/refs/heads/master
146-
147- RUN mkdir /build_ray
148- ADD ${RAY_RAW}/python/requirements.txt /build_ray/requirements.txt
149- ADD ${RAY_RAW}/python/requirements/test-requirements.txt /build_ray/test-requirements.txt
150- ADD ${RAY_RAW}/python/requirements_compiled.txt /build_ray/requirements_compiled.txt
151-
152- RUN PY_MINOR=$(/home/devuser/miniconda/bin/python -c "import sys; print(sys.version_info.minor)" ) \
123+ RUN mkdir -p /build_ray \
124+ && curl -fL -o /build_ray/requirements.txt ${RAY_RAW}/python/requirements.txt \
125+ && curl -fL -o /build_ray/test-requirements.txt ${RAY_RAW}/python/requirements/test-requirements.txt \
126+ && curl -fL -o /build_ray/requirements_compiled.txt ${RAY_RAW}/python/requirements_compiled.txt \
127+ && curl -fL -o /build_ray/.bazelversion ${RAY_RAW}/.bazelversion \
128+ && PY_MINOR=$(/home/devuser/miniconda/bin/python -c "import sys; print(sys.version_info.minor)" ) \
153129 && cd /build_ray \
154130 && if [ "$PY_MINOR" -lt 13 ]; then \
155131 sed -i 's/importlib-metadata==6.11.0/importlib-metadata>=7.0.0/' test-requirements.txt \
@@ -163,33 +139,23 @@ RUN PY_MINOR=$(/home/devuser/miniconda/bin/python -c "import sys; print(sys.vers
163139 && (/home/devuser/miniconda/bin/pip uninstall torch -y 2>/dev/null || true) \
164140 && (/home/devuser/miniconda/bin/pip uninstall ray -y 2>/dev/null || true) \
165141 && /home/devuser/miniconda/bin/pip install --no-cache-dir "numpy>=1.24,<1.27" \
166- && rm -rf /build_ray
167- ADD ${RAY_RAW}/.bazelversion /build_ray/.bazelversion
168- RUN BAZEL_VER=$(cat /build_ray/.bazelversion | tr -d '[:space:]' )\
169- && curl -fLO "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
170- && chmod +x "bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
171- && ./"bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
172- && rm -f "bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
173- && rm -rf /build_ray
174- # set RAM and CPU limits for the ray build
175- RUN echo "build --local_ram_resources=HOST_RAM*.5 --local_cpu_resources=25 --disk_cache=/home/devuser/bazel-cache" >> /home/devuser/.bazelrc
176-
177- # install claude
178- RUN curl -fsSL https://claude.ai/install.sh | bash
179-
180- # Ensure gcc/g++ point to the correct versioned compiler
181- RUN if [ -n "${GCC_SUFFIX}" ]; then \
182- rm -f /usr/bin/gcc /usr/bin/g++ \
183- && ln -s "/usr/bin/gcc${GCC_SUFFIX}" /usr/bin/gcc \
184- && ln -s "/usr/bin/g++${GCC_SUFFIX}" /usr/bin/g++; \
185- fi
186-
187- # NFS files may be owned by a different UID than the container user
188- RUN git config --system --add safe.directory '*'
189-
190- # Ensure devuser owns home and group can write (OpenShift random UID is in GID 0)
191- # Allow devuser to install system packages at runtime via sudo (e.g. sudo dnf install ...)
192- RUN echo "devuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/devuser \
142+ && BAZEL_VER=$(cat /build_ray/.bazelversion | tr -d '[:space:]' ) \
143+ && curl -fLO "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VER}/bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
144+ && chmod +x "bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
145+ && ./"bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
146+ && rm -f "bazel-${BAZEL_VER}-installer-linux-x86_64.sh" \
147+ && rm -rf /build_ray \
148+ && echo "build --local_ram_resources=HOST_RAM*.5 --local_cpu_resources=25 --disk_cache=/home/devuser/bazel-cache" >> /home/devuser/.bazelrc
149+
150+ # Layer 6: Claude, gcc symlinks, git config, sudoers, permissions
151+ RUN curl -fsSL https://claude.ai/install.sh | bash \
152+ && if [ -n "${GCC_SUFFIX}" ]; then \
153+ rm -f /usr/bin/gcc /usr/bin/g++ \
154+ && ln -s "/usr/bin/gcc${GCC_SUFFIX}" /usr/bin/gcc \
155+ && ln -s "/usr/bin/g++${GCC_SUFFIX}" /usr/bin/g++; \
156+ fi \
157+ && git config --system --add safe.directory '*' \
158+ && echo "devuser ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/devuser \
193159 && chmod 0440 /etc/sudoers.d/devuser \
194160 && chown -R devuser:0 /home/devuser && chmod -R g=u /home/devuser
195161
@@ -208,4 +174,4 @@ ENV CLAUDE_CODE_USE_VERTEX=1 \
208174 RAY_INSTALL_CPP=0 \
209175 RAY_DEBUG_BUILD=debug
210176
211- USER 1000
177+ USER 1000
0 commit comments