diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..d08830599 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +# System packages +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + git ca-certificates curl python3 python3-venv python3-pip && \ + rm -rf /var/lib/apt/lists/* + +# Fetch ComfyUI source +WORKDIR /opt/ComfyUI +COPY . /opt/ComfyUI + +# Python venv + pinned deps +RUN python3 -m venv /venv && \ + . /venv/bin/activate && \ + pip install --upgrade pip && \ + pip install --no-cache-dir "numpy<2" && \ + pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 \ + torch==2.2.2+cu121 torchvision==0.17.2+cu121 torchaudio==2.2.2+cu121 && \ + pip install --no-cache-dir -r requirements.txt && \ + pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cu121 \ + xformers==0.0.25.post1 triton==2.2.0 || true + +ENV PATH="/venv/bin:$PATH" \ + PYTHONUNBUFFERED=1 \ + COMFYUI_ROOT=/opt/ComfyUI + +# Allow CLI flags via env +ENV CLI_ARGS="" + +EXPOSE 8188 + +ENTRYPOINT ["bash", "-c", "python3 main.py --listen 0.0.0.0 --port 8188 $CLI_ARGS"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..01293cb9f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +services: + comfyui: + build: . + image: comfyui:local + container_name: comfyui + + user: root + + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] + + environment: + - NVIDIA_DRIVER_CAPABILITIES=compute,utility + - CLI_ARGS= + + ports: + - "8188:8188" + + volumes: + - ./models:/opt/ComfyUI/models:ro + - ./input:/opt/ComfyUI/input + - ./output:/opt/ComfyUI/output + - ./custom_nodes:/opt/ComfyUI/custom_nodes + + healthcheck: + test: ["CMD-SHELL", "curl -f http://localhost:8188 || exit 1"] + interval: 30s + timeout: 5s + retries: 3 + + restart: unless-stopped \ No newline at end of file