mirror of
https://github.com/AbdBarho/stable-diffusion-webui-docker.git
synced 2026-04-05 14:35:44 +00:00
Update
This commit is contained in:
parent
802d0bcd68
commit
ab47d2c699
15 changed files with 435 additions and 65 deletions
|
|
@ -1,4 +1,4 @@
|
|||
FROM alpine/git:2.36.2 as download
|
||||
FROM alpine/git:2.36.2 AS download
|
||||
|
||||
COPY clone.sh /clone.sh
|
||||
|
||||
|
|
@ -13,8 +13,8 @@ RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interr
|
|||
RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f
|
||||
RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets 6f7db241d2f8ba7457bac5ca9753331f0c266917
|
||||
|
||||
|
||||
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
|
||||
#FROM pytorch/pytorch:2.7.1-cuda12.8-cudnn9-runtime
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
|
||||
|
||||
|
|
@ -25,14 +25,12 @@ RUN --mount=type=cache,target=/var/cache/apt \
|
|||
# extensions needs those
|
||||
ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential
|
||||
|
||||
|
||||
WORKDIR /
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \
|
||||
cd stable-diffusion-webui && \
|
||||
git reset --hard v1.9.4 && \
|
||||
pip install -r requirements_versions.txt
|
||||
|
||||
# git reset --hard v1.9.4 && \
|
||||
pip install -r requirements_versions.txt && pip install --upgrade typing-extensions
|
||||
|
||||
ENV ROOT=/stable-diffusion-webui
|
||||
|
||||
|
|
@ -60,7 +58,8 @@ RUN \
|
|||
|
||||
WORKDIR ${ROOT}
|
||||
ENV NVIDIA_VISIBLE_DEVICES=all
|
||||
ENV CLI_ARGS=""
|
||||
EXPOSE 7860
|
||||
ARG CLI_ARGS=""
|
||||
ENV WEBUI_PORT=7860
|
||||
EXPOSE $WEBUI_PORT
|
||||
ENTRYPOINT ["/docker/entrypoint.sh"]
|
||||
CMD python -u webui.py --listen --port 7860 ${CLI_ARGS}
|
||||
CMD python -u webui.py --listen --port $WEBUI_PORT ${CLI_ARGS}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#set -x
|
||||
set -Eeuo pipefail
|
||||
|
||||
# TODO: move all mkdir -p ?
|
||||
|
|
@ -50,6 +50,7 @@ for to_path in "${!MOUNTS[@]}"; do
|
|||
rm -rf "${to_path}"
|
||||
if [ ! -f "$from_path" ]; then
|
||||
mkdir -vp "$from_path"
|
||||
# mkdir -vp "$from_path" || true
|
||||
fi
|
||||
mkdir -vp "$(dirname "${to_path}")"
|
||||
ln -sT "${from_path}" "${to_path}"
|
||||
|
|
|
|||
|
|
@ -1,22 +1,69 @@
|
|||
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
|
||||
# Defines the versions of ComfyUI, ComfyUI Manager, and PyTorch to use
|
||||
ARG COMFYUI_VERSION=v0.3.43
|
||||
ARG COMFYUI_MANAGER_VERSION=3.33.3
|
||||
ARG PYTORCH_VERSION=2.7.1-cuda12.8-cudnn9-runtime
|
||||
|
||||
# This image is based on the latest official PyTorch image, because it already contains CUDA, CuDNN, and PyTorch
|
||||
FROM pytorch/pytorch:${PYTORCH_VERSION}
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1
|
||||
|
||||
RUN apt-get update && apt-get install -y git && apt-get clean
|
||||
RUN apt update --assume-yes && \
|
||||
apt install --assume-yes \
|
||||
git \
|
||||
sudo \
|
||||
build-essential \
|
||||
libgl1-mesa-glx \
|
||||
libglib2.0-0 \
|
||||
libsm6 \
|
||||
libxext6 \
|
||||
ffmpeg && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ROOT=/stable-diffusion
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \
|
||||
cd ${ROOT} && \
|
||||
git checkout master && \
|
||||
git reset --hard 276f8fce9f5a80b500947fb5745a4dde9e84622d && \
|
||||
pip install -r requirements.txt
|
||||
# Clones the ComfyUI repository and checks out the latest release
|
||||
RUN git clone --depth=1 https://github.com/comfyanonymous/ComfyUI.git /opt/comfyui && \
|
||||
cd /opt/comfyui && \
|
||||
git fetch origin ${COMFYUI_VERSION} && \
|
||||
git checkout FETCH_HEAD
|
||||
|
||||
WORKDIR ${ROOT}
|
||||
# Clones the ComfyUI Manager repository and checks out the latest release; ComfyUI Manager is an extension for ComfyUI that enables users to install
|
||||
# custom nodes and download models directly from the ComfyUI interface; instead of installing it to "/opt/comfyui/custom_nodes/ComfyUI-Manager", which
|
||||
# is the directory it is meant to be installed in, it is installed to its own directory; the entrypoint will symlink the directory to the correct
|
||||
# location upon startup; the reason for this is that the ComfyUI Manager must be installed in the same directory that it installs custom nodes to, but
|
||||
# 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
|
||||
|
||||
# Installs the required Python packages for both ComfyUI and the ComfyUI Manager
|
||||
RUN pip install \
|
||||
--requirement /opt/comfyui/requirements.txt \
|
||||
--requirement /opt/comfyui-manager/requirements.txt
|
||||
|
||||
RUN pip3 install --no-cache-dir \
|
||||
opencv-python \
|
||||
diffusers \
|
||||
triton \
|
||||
sageattention \
|
||||
psutil
|
||||
|
||||
# Sets the working directory to the ComfyUI directory
|
||||
WORKDIR /opt/comfyui
|
||||
COPY . /docker/
|
||||
RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml ${ROOT}
|
||||
RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml /opt/comfyui
|
||||
|
||||
ENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH="${PYTHONPATH}:${PWD}" CLI_ARGS=""
|
||||
EXPOSE 7860
|
||||
ENTRYPOINT ["/docker/entrypoint.sh"]
|
||||
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}
|
||||
EXPOSE 7861
|
||||
|
||||
# Adds the startup script to the container; the startup script will create all necessary directories in the models and custom nodes volumes that were
|
||||
# mounted to the container and symlink the ComfyUI Manager to the correct directory; it will also create a user with the same UID and GID as the user
|
||||
# that started the container, so that the files created by the container are owned by the user that started the container and not the root user
|
||||
ENTRYPOINT ["/bin/bash", "/docker/entrypoint.sh"]
|
||||
|
||||
# On startup, ComfyUI is started at its default port; the IP address is changed from localhost to 0.0.0.0, because Docker is only forwarding traffic
|
||||
# to the IP address it assigns to the container, which is unknown at build time; listening to 0.0.0.0 means that ComfyUI listens to all incoming
|
||||
# traffic; the auto-launch feature is disabled, because we do not want (nor is it possible) to open a browser window in a Docker container
|
||||
CMD ["/opt/conda/bin/python", "main.py", "--listen", "0.0.0.0", "--port", "7861", "--disable-auto-launch"]
|
||||
|
|
|
|||
|
|
@ -1,31 +1,71 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -Eeuo pipefail
|
||||
|
||||
mkdir -vp /data/config/comfy/custom_nodes
|
||||
|
||||
declare -A MOUNTS
|
||||
|
||||
MOUNTS["/root/.cache"]="/data/.cache"
|
||||
MOUNTS["${ROOT}/input"]="/data/config/comfy/input"
|
||||
MOUNTS["${ROOT}/output"]="/output/comfy"
|
||||
|
||||
for to_path in "${!MOUNTS[@]}"; do
|
||||
set -Eeuo pipefail
|
||||
from_path="${MOUNTS[${to_path}]}"
|
||||
rm -rf "${to_path}"
|
||||
if [ ! -f "$from_path" ]; then
|
||||
mkdir -vp "$from_path"
|
||||
fi
|
||||
mkdir -vp "$(dirname "${to_path}")"
|
||||
ln -sT "${from_path}" "${to_path}"
|
||||
echo Mounted $(basename "${from_path}")
|
||||
# Creates the directories for the models inside of the volume that is mounted from the host
|
||||
echo "Creating directories for models..."
|
||||
MODEL_DIRECTORIES=(
|
||||
"checkpoints"
|
||||
"clip"
|
||||
"clip_vision"
|
||||
"configs"
|
||||
"controlnet"
|
||||
"diffusers"
|
||||
"diffusion_models"
|
||||
"embeddings"
|
||||
"gligen"
|
||||
"hypernetworks"
|
||||
"loras"
|
||||
"photomaker"
|
||||
"style_models"
|
||||
"text_encoders"
|
||||
"unet"
|
||||
"upscale_models"
|
||||
"vae"
|
||||
"vae_approx"
|
||||
)
|
||||
for MODEL_DIRECTORY in ${MODEL_DIRECTORIES[@]}; do
|
||||
mkdir -p /opt/comfyui/models/$MODEL_DIRECTORY
|
||||
done
|
||||
|
||||
if [ -f "/data/config/comfy/startup.sh" ]; then
|
||||
pushd ${ROOT}
|
||||
. /data/config/comfy/startup.sh
|
||||
popd
|
||||
fi
|
||||
# Creates the symlink for the ComfyUI Manager to the custom nodes directory, which is also mounted from the host
|
||||
echo "Creating symlink for ComfyUI Manager..."
|
||||
rm --force /opt/comfyui/custom_nodes/ComfyUI-Manager
|
||||
ln -s \
|
||||
/opt/comfyui-manager \
|
||||
/opt/comfyui/custom_nodes/ComfyUI-Manager
|
||||
|
||||
exec "$@"
|
||||
# The custom nodes that were installed using the ComfyUI Manager may have requirements of their own, which are not installed when the container is
|
||||
# started for the first time; this loops over all custom nodes and installs the requirements of each custom node
|
||||
echo "Installing requirements for custom nodes..."
|
||||
for CUSTOM_NODE_DIRECTORY in /opt/comfyui/custom_nodes/*;
|
||||
do
|
||||
if [ "$CUSTOM_NODE_DIRECTORY" != "/opt/comfyui/custom_nodes/ComfyUI-Manager" ];
|
||||
then
|
||||
if [ -f "$CUSTOM_NODE_DIRECTORY/requirements.txt" ];
|
||||
then
|
||||
CUSTOM_NODE_NAME=${CUSTOM_NODE_DIRECTORY##*/}
|
||||
CUSTOM_NODE_NAME=${CUSTOM_NODE_NAME//[-_]/ }
|
||||
echo "Installing requirements for $CUSTOM_NODE_NAME..."
|
||||
pip install --requirement "$CUSTOM_NODE_DIRECTORY/requirements.txt"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Under normal circumstances, the container would be run as the root user, which is not ideal, because the files that are created by the container in
|
||||
# the volumes mounted from the host, i.e., custom nodes and models downloaded by the ComfyUI Manager, are owned by the root user; the user can specify
|
||||
# the user ID and group ID of the host user as environment variables when starting the container; if these environment variables are set, a non-root
|
||||
# user with the specified user ID and group ID is created, and the container is run as this user
|
||||
if [ -z "$USER_ID" ] || [ -z "$GROUP_ID" ];
|
||||
then
|
||||
echo "Running container as $USER..."
|
||||
exec "$@"
|
||||
else
|
||||
echo "Creating non-root user..."
|
||||
getent group $GROUP_ID > /dev/null 2>&1 || groupadd --gid $GROUP_ID comfyui-user
|
||||
id -u $USER_ID > /dev/null 2>&1 || useradd --uid $USER_ID --gid $GROUP_ID --create-home comfyui-user
|
||||
chown --recursive $USER_ID:$GROUP_ID /opt/comfyui
|
||||
chown --recursive $USER_ID:$GROUP_ID /opt/comfyui-manager
|
||||
export PATH=$PATH:/home/comfyui-user/.local/bin
|
||||
|
||||
echo "Running container as $USER..."
|
||||
sudo --set-home --preserve-env=PATH --user \#$USER_ID "$@"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,25 +1,33 @@
|
|||
a111:
|
||||
base_path: /data
|
||||
base_path: /opt/comfyui
|
||||
# base_path: /data
|
||||
|
||||
checkpoints: models/Stable-diffusion
|
||||
configs: models/Stable-diffusion
|
||||
configs: models/configs
|
||||
vae: models/VAE
|
||||
loras: models/Lora
|
||||
loras: |
|
||||
models/Lora
|
||||
models/loras
|
||||
hypernetworks: models/hypernetworks
|
||||
controlnet: models/controlnet
|
||||
gligen: models/GLIGEN
|
||||
clip: models/CLIPEncoder
|
||||
embeddings: embeddings
|
||||
|
||||
unet: models/unet
|
||||
upscale_models: |
|
||||
models/RealESRGAN
|
||||
models/ESRGAN
|
||||
models/SwinIR
|
||||
models/GFPGAN
|
||||
hypernetworks: models/hypernetworks
|
||||
controlnet: models/ControlNet
|
||||
gligen: models/GLIGEN
|
||||
clip: models/CLIPEncoder
|
||||
embeddings: embeddings
|
||||
|
||||
custom_nodes: config/comfy/custom_nodes
|
||||
models/upscale_models
|
||||
diffusion_models: models/diffusion_models
|
||||
text_encoders: models/text_encoders
|
||||
clip_vision: models/clip_vision
|
||||
custom_nodes: /opt/comfyui/custom_nodes
|
||||
# custom_nodes: config/comfy/custom_nodes
|
||||
|
||||
# TODO: I am unsure about these, need more testing
|
||||
# style_models: config/comfy/style_models
|
||||
# t2i_adapter: config/comfy/t2i_adapter
|
||||
# clip_vision: config/comfy/clip_vision
|
||||
# diffusers: config/comfy/diffusers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue