Working Dockerfile and docker compose

This commit is contained in:
Scott Zupancic 2025-06-13 14:03:50 -04:00
parent c69af655aa
commit af0f199b18
2 changed files with 71 additions and 0 deletions

35
Dockerfile Normal file
View File

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

36
docker-compose.yml Normal file
View File

@ -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