Avatars / Dockerfile
Defter77's picture
Upload Dockerfile with huggingface_hub
126161d verified
FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04
# Environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
DEBIAN_FRONTEND=noninteractive
# System dependencies
RUN apt-get update && apt-get install -y \
python3.10 python3-pip git wget curl \
libgl1-mesa-glx libglib2.0-0 libsm6 libxrender1 libxext6 ffmpeg \
git-lfs \
&& rm -rf /var/lib/apt/lists/*
# Create app directory
WORKDIR /app
# Initialize Git LFS
RUN git lfs install
# Clone ComfyUI core with shallow clone
RUN git clone --depth 1 https://github.com/comfyanonymous/ComfyUI.git
# Clone custom nodes with shallow cloning to reduce download size and avoid rate limits
# Note: PuLID is now handled separately via COPY instead of git clone
RUN git clone --depth 1 https://github.com/cubiq/ComfyUI_IPAdapter_plus.git /app/ComfyUI/custom_nodes/IPAdapter_plus || echo "Failed to clone IPAdapter_plus but continuing" && \
git clone --depth 1 https://github.com/Kosinkadink/ComfyUI-KJNodes.git /app/ComfyUI/custom_nodes/KJNodes || echo "Failed to clone KJNodes but continuing" && \
git clone --depth 1 https://github.com/SSitu/ComfyUI_UltimateSDUpscale.git /app/ComfyUI/custom_nodes/UltimateSDUpscale || echo "Failed to clone UltimateSDUpscale but continuing" && \
git clone --depth 1 https://github.com/cg196/ComfyUI-UseEverywhere.git /app/ComfyUI/custom_nodes/UseEverywhere || echo "Failed to clone UseEverywhere but continuing" && \
git clone --depth 1 https://github.com/melMass/comfy-mtb.git /app/ComfyUI/custom_nodes/mtb || echo "Failed to clone mtb but continuing" && \
git clone --depth 1 https://github.com/LucianoCirino/ComfyUI_Masquerade.git /app/ComfyUI/custom_nodes/Masquerade || echo "Failed to clone Masquerade but continuing" && \
git clone --depth 1 https://github.com/Fannovel16/comfyui-save-image-with-geninfo.git /app/ComfyUI/custom_nodes/SaveGenInfo || echo "Failed to clone SaveGenInfo but continuing" && \
git clone --depth 1 https://github.com/jamesWalker55/comfyui-various.git /app/ComfyUI/custom_nodes/Various || echo "Failed to clone Various but continuing"
# Create directories for PuLID custom node
RUN mkdir -p /app/ComfyUI/custom_nodes/PuLID
# Create necessary directories
RUN mkdir -p /app/ComfyUI/models/checkpoints \
/app/ComfyUI/models/controlnet \
/app/ComfyUI/models/ipadapter \
/app/ComfyUI/models/pulid \
/app/ComfyUI/models/clip_vision \
/app/ComfyUI/input \
/app/ComfyUI/output \
/app/workflows \
/tmp/comfyui_user \
/tmp/comfyui_input \
/tmp/comfyui_output \
/tmp/comfyui_temp \
/tmp/workflows \
/tmp/comfyui_models \
/tmp/comfyui_models/pulid
# Set permissions for directories that need write access
RUN chmod -R 777 /app/ComfyUI/output \
/tmp/comfyui_user \
/tmp/comfyui_input \
/tmp/comfyui_output \
/tmp/comfyui_temp \
/tmp/workflows \
/tmp/comfyui_models \
|| echo "Failed to set permissions, continuing anyway"
# Copy all required application files
COPY requirements.txt .
COPY app.py .
COPY start.sh .
COPY download_models.py .
# Copy workflows if they exist, otherwise they'll be downloaded in start.sh
# Use a proper directory path with a trailing slash
COPY workflows/ /app/workflows/
# Initialize the PuLID directory - the actual content will be downloaded from Hugging Face
RUN echo "PuLID nodes will be downloaded at runtime" > /app/ComfyUI/custom_nodes/PuLID/README.txt
# Make scripts executable
RUN chmod +x /app/start.sh
# Install Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# Run model download script (will be overridden at runtime)
RUN python3 download_models.py || echo "Initial model download failed, will retry at runtime"
# Expose ports for Gradio and ComfyUI
EXPOSE 7860 8188
# Set the entrypoint
ENTRYPOINT ["/app/start.sh"]