Update dockerfile

This commit is contained in:
2025-07-07 03:53:01 +00:00
parent 5a36a4c866
commit b7a6d35c88
+96 -33
View File
@@ -1,61 +1,124 @@
FROM nvidia/cuda:12.8.1-cudnn-runtime-oraclelinux8 # Get cuda version from https://hub.docker.com/r/nvidia/cuda
FROM nvidia/cuda:12.9.1-devel-ubuntu20.04 AS build-deps
# Get release version from https://github.com/comfyanonymous/ComfyUI/releases ENV TZ=Etc/UTC
ENV ComfyUI_Release=0.3.43 ENV DEBIAN_FRONTEND=noninteractive
# Install build dependencies # Install build dependencies
RUN dnf update -y && dnf install -y \ RUN apt update -y && \
gcc \ apt install -y software-properties-common && \
gcc-c++ \ add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt update && \
apt install -y \
curl \
gcc-13 \
g++-13 \
make \ make \
wget \ wget \
libffi-devel \ libffi-dev \
openssl-devel \ libssl-dev \
bzip2-devel \ libbz2-dev \
zlib-devel \ zlib1g-dev \
xz-devel \ liblzma-dev \
readline-devel \ libreadline-dev \
sqlite-devel && \ libsqlite3-dev \
dnf clean all libopenblas-dev \
libblas-dev \
libjpeg-dev \
libpng-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libomp-dev \
libnuma-dev \
m4 \
cmake \
git \
ninja-build \
libprotobuf-dev \
protobuf-compiler \
libeigen3-dev \
zip \
unzip
# Set workdir for python # Build Python from source
FROM build-deps AS build-python
WORKDIR /usr/src WORKDIR /usr/src
# Download Python 3.11 source code (adjust version as needed) # Get release version from https://www.python.org/downloads/source/
RUN wget https://www.python.org/ftp/python/3.11.6/Python-3.11.6.tgz && \ ARG Python_Release=3.12.11
tar xzf Python-3.11.6.tgz
# Set new workdir for python RUN wget https://www.python.org/ftp/python/${Python_Release}/Python-${Python_Release}.tgz && \
WORKDIR /usr/src/Python-3.11.6 tar xzf Python-${Python_Release}.tgz
WORKDIR /usr/src/Python-${Python_Release}
# Build and install Python 3.11
RUN ./configure --enable-optimizations && \ RUN ./configure --enable-optimizations && \
make -j$(nproc) && \ make -j$(nproc) && \
make altinstall make altinstall
# Set python3.11 as default python and pip RUN Python_Version=$(echo "$Python_Release" | cut -d. -f1,2) && \
RUN ln -sf /usr/local/bin/python3.11 /usr/bin/python && \ ln -sf /usr/local/bin/python$Python_Version /usr/bin/python && \
ln -sf /usr/local/bin/pip3.11 /usr/bin/pip ln -sf /usr/local/bin/pip$Python_Version /usr/bin/pip
# Set workdir for application download # Build pytorch from souce
FROM build-python AS build-pytorch
WORKDIR /usr/src
# Get release version from https://github.com/pytorch/pytorch/releases
ARG Pytorch_Release=2.7.1
# Set the number of jobs for the Pytorch_Build -> (Gb of RAM)/17 rounded down to the nearest whole number
ARG Pytorch_Jobs=4
# Set the CUDA arch to compile for
ARG CUDA_ARCH_LIST="7.5;8.0;8.6;8.9"
RUN git clone --recursive -b v${Pytorch_Release} https://github.com/pytorch/pytorch.git
WORKDIR /usr/src/pytorch
ENV USE_CUDA=1 \
USE_CUDNN=1 \
BUILD_CAFFE2=0 \
USE_DISTRIBUTED=0 \
USE_FBGEMM=0 \
USE_MKLDNN=0 \
USE_NCCL=0 \
USE_QNNPACK=0 \
USE_XNNPACK=0 \
USE_OPENMP=0 \
USE_TENSORPIPE=0 \
USE_SYSTEM_EIGEN_INSTALL=0 \
BUILD_TEST=0 \
CMAKE_PREFIX_PATH="/usr/local/cuda" \
CUDA_HOME="/usr/local/cuda" \
USE_NVRTC=1
RUN python -m pip install numpy typing_extensions future sympy
RUN pip install -r requirements.txt
RUN git submodule sync && \
git submodule update --init --recursive
RUN MAX_JOBS=${Pytorch_Jobs} && \
TORCH_CUDA_ARCH_LIST=${CUDA_ARCH_LIST} && \
python setup.py install
# Build ComfyUI from source
FROM build-pytorch AS publish
WORKDIR /app WORKDIR /app
# Pull source and extract # Get release version from https://github.com/comfyanonymous/ComfyUI/releases
ARG ComfyUI_Release=0.3.43
RUN wget https://github.com/comfyanonymous/ComfyUI/archive/refs/tags/v${ComfyUI_Release}.tar.gz && \ RUN wget https://github.com/comfyanonymous/ComfyUI/archive/refs/tags/v${ComfyUI_Release}.tar.gz && \
tar xzf v${ComfyUI_Release}.tar.gz && \ tar xzf v${ComfyUI_Release}.tar.gz && \
rm v${ComfyUI_Release}.tar.gz && \ rm v${ComfyUI_Release}.tar.gz && \
mv /app/ComfyUI-${ComfyUI_Release} /app/comfyui/ mv /app/ComfyUI-${ComfyUI_Release} /app/comfyui/
# Set workdir for application
WORKDIR /app/comfyui WORKDIR /app/comfyui
# Upgrade pip and install dependencies
RUN python -m pip install --upgrade pip && \ RUN python -m pip install --upgrade pip && \
python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128 && \
python -m pip install -r requirements.txt python -m pip install -r requirements.txt
# Expose the port
EXPOSE 8188 EXPOSE 8188
# Start CompyUI CMD ["python", "main.py", "--listen", "0.0.0.0"]
CMD ["python", "main.py"]