File size: 2,759 Bytes
40fe655
 
 
 
 
 
 
 
 
 
 
 
d78f71a
40fe655
 
 
 
 
 
 
 
 
 
 
 
 
d78f71a
 
89ecfb3
50211a2
40fe655
1d58eb7
 
40fe655
50211a2
40fe655
50211a2
40fe655
50211a2
 
 
40fe655
89ecfb3
50211a2
 
40fe655
 
 
50211a2
40fe655
50211a2
 
40fe655
50211a2
40fe655
 
 
 
 
 
 
 
 
 
 
 
 
 
50211a2
40fe655
 
 
 
 
 
 
 
 
 
 
 
50211a2
40fe655
 
 
 
 
 
 
 
50211a2
40fe655
50211a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40fe655
 
 
 
 
 
 
 
 
 
50211a2
 
 
 
 
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
FROM python:3.10-slim

ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PORT=7860

ENV OMP_NUM_THREADS=2
ENV MKL_NUM_THREADS=2
ENV OPENBLAS_NUM_THREADS=2
ENV NUMEXPR_NUM_THREADS=2

RUN apt-get update && apt-get install -y --no-install-recommends \
    git \
    git-lfs \
    curl \
    wget \
    ffmpeg \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender1 \
    libgomp1 \
    ca-certificates \
    build-essential \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

RUN useradd --create-home --shell /bin/bash --uid 1000 user

WORKDIR /app

RUN pip install --no-cache-dir \
    --upgrade pip setuptools wheel

# CPU-only PyTorch
RUN pip install --no-cache-dir \
    "torch==2.7.1" \
    "torchvision==0.22.1" \
    "torchaudio==2.7.1" \
    --index-url https://download.pytorch.org/whl/cpu

# ComfyUI
RUN git clone --depth 1 \
    https://github.com/comfyanonymous/ComfyUI.git \
    /app/ComfyUI

WORKDIR /app/ComfyUI

# ComfyUI requirements
RUN pip install --no-cache-dir -r requirements.txt

# Extra packages for your workflow
RUN pip install --no-cache-dir \
    huggingface_hub \
    psutil \
    websocket-client \
    opencv-python-headless \
    einops \
    transformers \
    safetensors \
    color-matcher \
    scikit-image \
    numba \
    dynamicprompts \
    diffusers

# Model directories
RUN mkdir -p \
    /app/ComfyUI/models/checkpoints \
    /app/ComfyUI/models/diffusion_models \
    /app/ComfyUI/models/text_encoders \
    /app/ComfyUI/models/vae \
    /app/ComfyUI/models/loras \
    /app/ComfyUI/models/upscale_models \
    /app/ComfyUI/models/clip \
    /app/ComfyUI/input \
    /app/ComfyUI/output \
    /app/ComfyUI/temp

# Fix permissions
RUN chown -R user:user /app

USER user

ENV HOME=/home/user
ENV PATH=/home/user/.local/bin:$PATH
ENV PYTHONPATH=/app/ComfyUI

WORKDIR /app/ComfyUI

# Diagnostic check
RUN python - <<'PY'
import torch
import comfy_kitchen

print("=" * 60)
print("PyTorch:", torch.__version__)
print("CUDA available:", torch.cuda.is_available())
print("CUDA version:", torch.version.cuda)
print("comfy_kitchen:", comfy_kitchen.__file__)
print("int8_attention_is_available:",
      hasattr(comfy_kitchen, "int8_attention_is_available"))
print("=" * 60)

assert torch.__version__.startswith("2.7.1")
assert not torch.cuda.is_available()
assert hasattr(comfy_kitchen, "int8_attention_is_available")
PY

EXPOSE 7860

HEALTHCHECK \
    --interval=30s \
    --timeout=10s \
    --start-period=180s \
    --retries=5 \
    CMD curl -f http://127.0.0.1:7860/system_stats || exit 1

CMD ["python", "-u", "main.py", \
     "--cpu", \
     "--listen", "0.0.0.0", \
     "--port", "7860", \
     "--output-directory", "/app/ComfyUI/output"]