forked from Comfy-Org/ComfyUI
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
118 lines (104 loc) · 4.84 KB
/
Copy pathDockerfile
File metadata and controls
118 lines (104 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
FROM python:3.12.13-slim-trixie
# Environment
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
COMFY_AUTO_INSTALL=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
PIP_NO_CACHE_DIR=1 \
PIP_BREAK_SYSTEM_PACKAGES=1 \
PIP_USE_PEP517=1 \
EXT_PARALLEL=4 \
NVCC_APPEND_FLAGS="--threads 8" \
MAX_JOBS=32 \
SAGE_ATTENTION_AVAILABLE=0 \
COMFYUI_PATH=/app/ComfyUI \
COMFYUI_MODEL_PATH=/app/ComfyUI/models \
COMFYUI_MODELS_PATH=/app/ComfyUI/models
# Install system deps + CUDA toolkit
# The NVIDIA CUDA repo key uses SHA1 which trixie's sqv rejects since 2026-02-01.
# We add the repo directly with [trusted=yes] to bypass this; the packages still
# come over HTTPS from NVIDIA's official CDN. The non-free.list is not needed
# since all CUDA packages come from NVIDIA's own repo, not Debian non-free.
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
build-essential \
cmake \
libgl1 \
libglx-mesa0 \
libglib2.0-0 \
fonts-dejavu-core \
fontconfig \
util-linux \
wget \
gnupg2 \
ca-certificates \
ninja-build \
patch \
pkg-config \
libcairo2-dev \
&& echo "deb [trusted=yes] https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/ /" > /etc/apt/sources.list.d/cuda.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
cuda-nvcc-12-8 \
cuda-cudart-dev-12-8 \
libcusparse-dev-12-8 \
libcublas-dev-12-8 \
libcurand-dev-12-8 \
libcusolver-dev-12-8 \
libcufft-dev-12-8 \
nvidia-smi \
&& rm -rf /var/lib/apt/lists/*
# Patch CUDA math_functions.h for glibc 2.41 compatibility (trixie uses glibc 2.41)
RUN sed -i 's/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x);/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double sinpi(double x) noexcept (true);/' /usr/local/cuda-12.8/include/crt/math_functions.h && \
sed -i 's/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x);/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float sinpif(float x) noexcept (true);/' /usr/local/cuda-12.8/include/crt/math_functions.h && \
sed -i 's/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x);/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double cospi(double x) noexcept (true);/' /usr/local/cuda-12.8/include/crt/math_functions.h && \
sed -i 's/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x);/extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float cospif(float x) noexcept (true);/' /usr/local/cuda-12.8/include/crt/math_functions.h
# Set CUDA paths for entrypoint compilation
ENV CUDA_HOME=/usr/local/cuda-12.8 \
PATH=/usr/local/cuda-12.8/bin:${PATH} \
LD_LIBRARY_PATH=/usr/local/cuda-12.8/lib64
# Create symlink for compatibility
RUN ln -sf /usr/local/cuda-12.8 /usr/local/cuda
# Create runtime user/group
RUN set -e; \
if getent group 1000 >/dev/null 2>&1; then \
EXISTING_GROUP=$(getent group 1000 | cut -d: -f1); \
if [ "$EXISTING_GROUP" != "appuser" ]; then groupadd appuser; fi; \
else \
groupadd --gid 1000 appuser; \
fi; \
if getent passwd 1000 >/dev/null 2>&1; then \
EXISTING_USER=$(getent passwd 1000 | cut -d: -f1); \
if [ "$EXISTING_USER" != "appuser" ]; then useradd --gid appuser --create-home --shell /bin/bash appuser; fi; \
else \
useradd --uid 1000 --gid appuser --create-home --shell /bin/bash appuser; \
fi; \
mkdir -p /home/appuser; \
chown appuser:appuser /home/appuser
# Workdir
WORKDIR /app/ComfyUI
# Copy requirements with optional handling
COPY requirements.txt* ./
# Core Python deps (torch CUDA 12.8, pin Triton, plus common deps)
RUN python -m pip install --upgrade pip setuptools wheel \
&& python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128 \
&& python -m pip install --prefer-binary cupy-cuda12x \
&& if [ -f requirements.txt ]; then python -m pip install -r requirements.txt; fi \
&& python -m pip install imageio-ffmpeg "av>=14.2" nvidia-ml-py onnxruntime-gpu \
&& python -m pip install toml GitPython
# Copy the application
COPY . .
# Pre-bake ComfyUI-Manager
RUN mkdir -p /app/ComfyUI/custom_nodes \
&& if [ ! -d "/app/ComfyUI/custom_nodes/ComfyUI-Manager" ]; then \
git clone --depth 1 https://github.com/ltdrdata/ComfyUI-Manager.git /app/ComfyUI/custom_nodes/ComfyUI-Manager || true; \
fi
# Entrypoint
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh \
&& chown appuser:appuser /app /home/appuser /entrypoint.sh
EXPOSE 8188
# Start as root so entrypoint can adjust ownership and drop privileges
USER root
ENTRYPOINT ["/entrypoint.sh"]
CMD ["python", "main.py", "--listen", "0.0.0.0"]