-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
155 lines (133 loc) · 5.14 KB
/
Dockerfile
File metadata and controls
155 lines (133 loc) · 5.14 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# ============================================================================
# Stage 1: Builder - Clone ComfyUI and install all Python packages
# ============================================================================
FROM ubuntu:22.04 AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install minimal dependencies needed for building
RUN apt-get update && \
apt-get install -y --no-install-recommends \
software-properties-common \
gpg-agent \
git \
wget \
curl \
ca-certificates \
&& add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y --no-install-recommends \
python3.12 \
python3.12-venv \
python3.12-dev \
build-essential \
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \
&& dpkg -i cuda-keyring_1.1-1_all.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends cuda-minimal-build-12-4 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm cuda-keyring_1.1-1_all.deb
# Install pip for Python 3.12 and upgrade it
RUN curl -sS https://bootstrap.pypa.io/get-pip.py -o get-pip.py && \
python3.12 get-pip.py && \
python3.12 -m pip install --upgrade pip && \
rm get-pip.py
# Set CUDA environment for building
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64
# Clone ComfyUI to get requirements
WORKDIR /tmp/build
RUN git clone https://github.com/comfyanonymous/ComfyUI.git
# Clone custom nodes to get their requirements
WORKDIR /tmp/build/ComfyUI/custom_nodes
RUN git clone https://github.com/ltdrdata/ComfyUI-Manager.git
# Install PyTorch and all ComfyUI dependencies
RUN python3.12 -m pip install --no-cache-dir \
torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
WORKDIR /tmp/build/ComfyUI
RUN python3.12 -m pip install --no-cache-dir -r requirements.txt && \
python3.12 -m pip install --no-cache-dir GitPython opencv-python
# Install custom node dependencies
WORKDIR /tmp/build/ComfyUI/custom_nodes
RUN for node_dir in */; do \
if [ -f "$node_dir/requirements.txt" ]; then \
echo "Installing requirements for $node_dir"; \
python3.12 -m pip install --no-cache-dir -r "$node_dir/requirements.txt" || true; \
fi; \
done
# ============================================================================
# Stage 2: Runtime - Clean image with pre-installed packages
# ============================================================================
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV IMAGEIO_FFMPEG_EXE=/usr/bin/ffmpeg
ENV FILEBROWSER_CONFIG=/workspace/runpod-slim/.filebrowser.json
# Update and install runtime dependencies, CUDA, and common tools
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
software-properties-common \
gpg-agent \
&& add-apt-repository ppa:deadsnakes/ppa && \
add-apt-repository ppa:cybermax-dexter/ffmpeg-nvenc && \
apt-get update && \
apt-get install -y --no-install-recommends \
git \
python3.12 \
python3.12-venv \
python3.12-dev \
build-essential \
wget \
gnupg \
xz-utils \
openssh-client \
openssh-server \
nano \
curl \
htop \
tmux \
ca-certificates \
less \
rsync \
socat \
iproute2 \
net-tools \
iputils-ping \
procps \
golang \
make \
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb \
&& dpkg -i cuda-keyring_1.1-1_all.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends cuda-minimal-build-12-4 \
&& apt-get install -y --no-install-recommends ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm cuda-keyring_1.1-1_all.deb
# Copy Python packages and pip executables from builder stage
COPY --from=builder /usr/local/lib/python3.12 /usr/local/lib/python3.12
COPY --from=builder /usr/local/bin /usr/local/bin
# Remove uv to force ComfyUI-Manager to use pip (uv doesn't respect --system-site-packages properly)
RUN pip uninstall -y uv 2>/dev/null || true && \
rm -f /usr/local/bin/uv /usr/local/bin/uvx
# Set CUDA environment variables
ENV PATH=/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64
# Install comfy-cli
RUN pip install comfy-cli
# Configure SSH for root login
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
mkdir -p /run/sshd
# Create workspace directory
RUN mkdir -p /workspace/runpod-slim
WORKDIR /workspace/runpod-slim
# Expose ports
EXPOSE 8188 22
# Copy and set up start script
COPY start.sh /start.sh
RUN chmod +x /start.sh
# Set Python 3.12 as default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
update-alternatives --set python3 /usr/bin/python3.12
ENTRYPOINT ["/start.sh"]