From dfde056a225671f15c0d83a35402b38955c9638b Mon Sep 17 00:00:00 2001 From: fapoverflow <50244958+fapoverflow@users.noreply.github.com> Date: Sun, 30 Nov 2025 03:38:39 +0100 Subject: [PATCH] Update comfyui image & add ai toolkit --- .gitignore | 1 + docker-compose.yml | 28 +++++++ services/ai-toolkit/Dockerfile | 7 ++ services/ai-toolkit/entrypoint.sh | 7 ++ services/comfy/Dockerfile | 121 ++++++++++++++++++++++++++++-- 5 files changed, 156 insertions(+), 8 deletions(-) create mode 100644 services/ai-toolkit/Dockerfile create mode 100644 services/ai-toolkit/entrypoint.sh diff --git a/.gitignore b/.gitignore index 9d34c3f..4eaf900 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /.vscode .idea TODO.md +*.env diff --git a/docker-compose.yml b/docker-compose.yml index bb740c5..c8ee8c0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -77,6 +77,8 @@ services: container_name: comfy build: ./services/comfy image: sd-comfy:latest +# command: +# - python main.py --preview-method auto --force-fp16 volumes: - ./data/models:/opt/comfyui/models - ./data/config/configs:/opt/comfyui/user/default/ @@ -145,3 +147,29 @@ services: image: sd-fooocus:latest environment: - CLI_ARGS= + + ai-toolkit: + <<: *base_service + profiles: [ "ai-toolkit" ] + container_name: ai-toolkit + build: ./services/ai-toolkit + image: sd-aitoolkit:latest + ports: + - "8675:8675" + volumes: + - ./data/.cache/huggingface/hub:/root/.cache/huggingface/hub +# - ./data/aitk_db.db:/app/ai-toolkit/aitk_db.db + - ./data/datasets:/app/ai-toolkit/datasets + - ./data/config/ai-toolkit:/app/ai-toolkit/config + - ./data/models:/app/ai-toolkit/models + - ./output/ai-toolkit:/app/ai-toolkit/output + environment: + - AI_TOOLKIT_AUTH=${AI_TOOLKIT_AUTH:-password} + - NODE_ENV=production + - TZ=UTC + secrets: + - my_secret + +secrets: + my_secret: + file: ./services/ai-toolkit/secret.env diff --git a/services/ai-toolkit/Dockerfile b/services/ai-toolkit/Dockerfile new file mode 100644 index 0000000..1c9f5d2 --- /dev/null +++ b/services/ai-toolkit/Dockerfile @@ -0,0 +1,7 @@ +FROM ostris/aitoolkit:latest + +ADD --chmod=755 entrypoint.sh /docker/ + +ENTRYPOINT ["/bin/bash", "/docker/entrypoint.sh"] +CMD ["/start.sh"] + diff --git a/services/ai-toolkit/entrypoint.sh b/services/ai-toolkit/entrypoint.sh new file mode 100644 index 0000000..ebd5981 --- /dev/null +++ b/services/ai-toolkit/entrypoint.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# get envs files and export envars +export $(egrep -v '^#' /run/secrets/* | xargs) +# if need some specific file, where password is the secret name +# export $(egrep -v '^#' /run/secrets/password| xargs) +# call the dockerfile's entrypoint +source /start.sh diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index 340029d..c0268e6 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -1,7 +1,9 @@ # Defines the versions of ComfyUI, ComfyUI Manager, and PyTorch to use -ARG COMFYUI_VERSION=v0.3.59 -ARG COMFYUI_MANAGER_VERSION=3.35 -ARG PYTORCH_VERSION=2.8.0-cuda12.9-cudnn9-runtime +ARG COMFYUI_VERSION=v0.3.71 +#ARG COMFYUI_MANAGER_VERSION=3.35 +ARG PYTORCH_VERSION=2.9.1-cuda13.0-cudnn9-devel +# number of CPU's use for compilation +ARG CPUS=10 # This image is based on the latest official PyTorch image, because it already contains CUDA, CuDNN, and PyTorch FROM pytorch/pytorch:${PYTORCH_VERSION} @@ -17,7 +19,42 @@ RUN apt update --assume-yes && \ libglib2.0-0 \ libsm6 \ libxext6 \ - ffmpeg && \ + autoconf \ + automake \ + cmake \ + git-core \ + libass-dev \ + libfreetype6-dev \ + libgnutls28-dev \ + libmp3lame-dev \ + libsdl2-dev \ + libtool \ + libva-dev \ + libvdpau-dev \ + libvorbis-dev \ + libxcb1-dev \ + libxcb-shm0-dev \ + libxcb-xfixes0-dev \ + meson \ + ninja-build \ + pkg-config \ + texinfo \ + wget \ + yasm \ + zlib1g-dev \ + nasm \ + libunistring-dev \ + libaom-dev \ + libx265-dev \ + libx264-dev \ + libnuma-dev \ + libfdk-aac-dev \ + libc6 \ + libc6-dev \ + unzip \ + libnuma1 \ +# ffmpeg \ + && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* @@ -34,9 +71,10 @@ RUN git clone --depth=1 https://github.com/comfyanonymous/ComfyUI.git /opt/comfy # this directory is mounted as a volume, so that the custom nodes are not installed inside of the container and are not lost when the container is # removed; this way, the custom nodes are installed on the host machine RUN git clone --depth=1 https://github.com/Comfy-Org/ComfyUI-Manager.git /opt/comfyui-manager && \ - cd /opt/comfyui-manager && \ - git fetch origin ${COMFYUI_MANAGER_VERSION} && \ - git checkout FETCH_HEAD + cd /opt/comfyui-manager +# cd /opt/comfyui-manager && \ +# git fetch origin ${COMFYUI_MANAGER_VERSION} && \ +# git checkout FETCH_HEAD # Installs the required Python packages for both ComfyUI and the ComfyUI Manager RUN pip install \ @@ -47,8 +85,75 @@ RUN pip3 install --no-cache-dir \ opencv-python \ diffusers \ triton \ + torchsde \ + nvidia-ml-py \ sageattention \ - psutil + flash-attention \ + psutil \ + nvitop + +# compile ffmpeg +RUN mkdir -p ~/ffmpeg_sources ~/bin && \ + cd ~/ffmpeg_sources && \ + wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \ + tar xjvf ffmpeg-snapshot.tar.bz2 && \ + cd ffmpeg && \ + PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ + --prefix="$HOME/ffmpeg_build" \ + --pkg-config-flags="--static" \ + --extra-cflags="-I$HOME/ffmpeg_build/include" \ + --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ + --extra-libs="-lpthread -lm" \ + --ld="g++" \ + --bindir="$HOME/bin" \ + --enable-gpl \ + --enable-gnutls \ + --enable-libass \ + --enable-libfdk-aac \ + --enable-libfreetype \ + --enable-libmp3lame \ + --enable-libx264 \ + --enable-libx265 \ + --enable-nonfree && \ + PATH="$HOME/bin:$PATH" make -j $CPUS && \ + make install && \ + hash -r + +# install ffmpeg-nvidia adapter +RUN mkdir ~/nv && cd ~/nv && \ + git clone https://github.com/FFmpeg/nv-codec-headers.git && \ + cd nv-codec-headers && make install + +# compile ffmpeg with cuda +RUN cd ~/nv && \ + git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/ && \ + cd ffmpeg && \ + ./configure \ + --enable-nonfree \ + --enable-nvenc \ + --enable-cuda \ + --enable-cuda-nvcc \ + --enable-cuvid \ + --extra-cflags=-I/usr/local/cuda/include \ + --extra-ldflags=-L/usr/local/cuda/lib64 \ + --disable-static \ + --enable-gpl \ + --enable-gnutls \ + --enable-shared \ + --enable-libaom \ + --enable-libass \ + --enable-libfdk-aac \ + --enable-libfreetype \ + --enable-libmp3lame \ + --enable-libvorbis \ + --enable-libx264 \ + --enable-libx265 \ +# --enable-libnpp \ # ERROR: libnpp support is deprecated, version 13.0 and up are not supported \ +# --enable-libopus \ # not found : install ? +# --enable-libvpx \ + && \ + make -j $CPUS && \ + make install # Pre-install previously used custom nodes requirements from volume COPY ./install/merged-requirements.txt* /docker/requirements.txt