comfy-ui-api / Dockerfile
Anatole RAIMBERT
[CONF] changed dockerfile to enable nvidia gpu usage
9967d2a
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Europe/Paris
ARG USE_PERSISTENT_DATA
RUN apt-get update && apt-get install -y \
git \
make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git git-lfs \
ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install
# User
RUN useradd -m --groups users,sudo -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Pyenv
RUN curl https://pyenv.run | bash
ENV PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH
ARG PYTHON_VERSION=3.10.12
# Python
RUN pyenv install $PYTHON_VERSION && \
pyenv global $PYTHON_VERSION && \
pyenv rehash && \
pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir \
datasets \
huggingface-hub "protobuf<4" "click<8.1"
# Set the working directory to /data if USE_PERSISTENT_DATA is set, otherwise set to $HOME/app
WORKDIR $HOME/app
# Copy the current directory contents into the container at $HOME/comfy setting the owner to the user
RUN git clone https://github.com/comfyanonymous/ComfyUI . && git checkout v0.3.15 && \
pip install xformers!=0.0.18 --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121
# Workflows
RUN echo "Adding workflows..."
ADD ./workflows ./user/default/workflows
# Checkpoints
RUN echo "Downloading checkpoints..."
# Quiet because it's a big file (2.13 GB)
RUN wget -c https://huggingface.co/genai-archive/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.fp16.safetensors -P ./models/checkpoints/ --quiet
# VAE
RUN echo "Downloading VAE..."
RUN wget -c https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors -P ./models/vae/
# Loras
RUN echo "Downloading Loras..."
RUN wget -c https://huggingface.co/2ndChanceParis/industrial-lora/resolve/main/industrial_lora-07.safetensors -P ./models/loras
# CLIP model
RUN echo "Downloading CLIP models..."
# Quiet because it's a big file (9.79 GB)
RUN wget -c https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp16.safetensors -P ./models/clip/ --quiet
RUN wget -c https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors -P ./models/clip/
# Unet model
RUN echo "Downloading Unet models..."
# Quiet because it's a big file (23.8 GB)
RUN wget -c https://huggingface.co/camenduru/FLUX.1-dev/resolve/fc63f3204a12362f98c04bc4c981a06eb9123eee/flux1-canny-dev.safetensors -P ./models/unet/ --quiet
# --- Optional models ---
# Not used at the moment
# T2I-Adapter
# RUN echo "Downloading T2I-Adapters..."
# RUN wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_depth_sd14v1.pth -P ./models/controlnet/
# T2I Styles Model
# RUN echo "Downloading T2I-Style models..."
# RUN wget -c https://huggingface.co/TencentARC/T2I-Adapter/resolve/main/models/t2iadapter_style_sd14v1.pth -P ./models/style_models/
# CLIPVision model (needed for styles model)
# RUN echo "Downloading CLIPVision models..."
# RUN wget -c https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin -O ./models/clip_vision/clip_vit14.bin
# ControlNet
# RUN echo "Downloading ControlNet models..."
# RUN wget -c https://huggingface.co/comfyanonymous/ControlNet-v1-1_fp16_safetensors/resolve/main/control_v11e_sd15_ip2p_fp16.safetensors -P ./models/controlnet/
# GLIGEN
#RUN echo "Downloading GLIGEN models..."
#RUN wget -c https://huggingface.co/comfyanonymous/GLIGEN_pruned_safetensors/resolve/main/gligen_sd14_textbox_pruned_fp16.safetensors -P ./models/gligen/
# ESRGAN upscale model
#RUN echo "Downloading ESRGAN upscale models..."
#RUN wget -c https://github.com/xinntao/Real-ESRGAN/releases/download/v0.1.0/RealESRGAN_x4plus.pth -P ./models/upscale_models/
RUN echo "Done"
# instal custom nodes
RUN echo "Installing custom nodes..."
RUN cd custom_nodes && git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git
RUN cd custom_nodes && git clone https://github.com/rgthree/rgthree-comfy.git && cd rgthree-comfy && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/chflame163/ComfyUI_LayerStyle.git && cd ComfyUI_LayerStyle && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/WASasquatch/was-node-suite-comfyui/ && cd was-node-suite-comfyui && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/kijai/ComfyUI-KJNodes.git && cd ComfyUI-KJNodes && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/cubiq/ComfyUI_essentials.git && cd ComfyUI_essentials && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/john-mnz/ComfyUI-Inspyrenet-Rembg.git && cd ComfyUI-Inspyrenet-Rembg && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/sipherxyz/comfyui-art-venture.git && cd comfyui-art-venture && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/Layer-norm/comfyui-lama-remover.git && cd comfyui-lama-remover && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/pydn/ComfyUI-to-Python-Extension.git && cd ComfyUI-to-Python-Extension && pip install -r requirements.txt
RUN cd custom_nodes && git clone https://github.com/twri/sdxl_prompt_styler.git
RUN cd custom_nodes && git clone https://github.com/M1kep/ComfyLiterals.git
RUN cd custom_nodes && git clone https://github.com/hylarucoder/comfyui-copilot.git
# ComfyUI Manager
RUN echo "Installing ComfyUI Manager..."
RUN cd custom_nodes && git clone https://github.com/ltdrdata/ComfyUI-Manager.git
RUN echo "Done"
CMD ["python", "main.py", "--listen", "0.0.0.0", "--port", "7860", "--output-directory", "${USE_PERSISTENT_DATA:+/data/}"]