# 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"]