File size: 1,442 Bytes
17e7e4a
6252d42
907fe4e
 
a070074
6252d42
a30b396
 
 
907fe4e
6252d42
f1b0640
 
aa30867
907fe4e
 
 
 
6252d42
a30b396
 
 
fda9c1a
a30b396
 
a8a5eb0
aa30867
 
 
6252d42
 
30e4133
c3b9cdb
 
 
6252d42
a070074
a30b396
c3b9cdb
907fe4e
aa30867
6252d42
f1b0640
aa30867
f1b0640
 
907fe4e
a070074
30e4133
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
# syntax=docker/dockerfile:1.4

FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive

# System deps
RUN apt-get update && apt-get install -y \
    python3 python3-venv python3-pip git wget \
 && rm -rf /var/lib/apt/lists/*

# Create comfy user
RUN useradd -m -s /bin/bash comfy

# Clone ComfyUI
WORKDIR /workspace
RUN git clone https://github.com/comfyanonymous/ComfyUI.git
WORKDIR /workspace/ComfyUI

# Python venv + deps
RUN python3 -m venv .venv \
 && . .venv/bin/activate \
 && pip install --upgrade pip \
 && pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu \
 && pip install huggingface_hub xformers!=0.0.18 \
 && pip install -r requirements.txt

# ✅ Add ComfyUI-Manager extension
RUN git clone https://github.com/Comfy-Org/ComfyUI-Manager.git /workspace/ComfyUI/custom_nodes/ComfyUI-Manager

# Pre-create folders
RUN mkdir -p /workspace/ComfyUI/user/default /workspace/ComfyUI/temp /workspace/ComfyUI/db

# Copy download script
COPY download_flux.py /workspace/ComfyUI/download_flux.py

# Download models as root
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
    . .venv/bin/activate && \
    python download_flux.py

# ✅ Ownership
RUN chown -R comfy:comfy /workspace && chmod -R 777 /workspace

# Switch to comfy user
USER comfy

EXPOSE 7860

CMD ["/bin/bash", "-c", "source .venv/bin/activate && python3 main.py --listen 0.0.0.0 --port 7860 --cpu --use-split-cross-attention"]