mirror of
https://github.com/AbdBarho/stable-diffusion-webui-docker.git
synced 2025-10-27 00:04:16 -04:00
This commit refactors the `docker-compose.yml` and `Dockerfile` to simplify the management of environment variables and user/group configurations. The following changes were made: 1. **Environment Variables via `.env` File:** - Added `env_file: .env` in the base service configuration within `docker-compose.yml`. This allows for centralized management of environment variables, making it easier to configure different environments without modifying Docker files directly. 2. **User/Group Configuration Simplification:** - Removed hardcoded user and group settings (`USE_UID`, `USE_GID`, `USE_USER`, `USE_GROUP`) from the `docker-compose.yml` file. - Updated the `Dockerfile` to use default values of `0` for `USE_UID` and `USE_GID`, and `root` for `USE_USER` and `USE_GROUP`. This aligns with common practices where root is often used in containerized environments unless specified otherwise. 3. **Conditional Dependency Handling:** - Introduced conditional logic to enable dependencies like Krita based on the value of `USE_KRITA`. - Simplified the environment variable assignments within the Dockerfile, ensuring that only necessary variables are set. 4. **Entrypoint Script Enhancements:** - Added a feature in the `entrypoint.sh` script to update custom nodes by pulling the latest changes from their respective repositories if `UPDATE_CUSTOM_NODES` is set to `true`. These changes improve the maintainability and flexibility of the Docker setup, making it easier to adapt to different deployment scenarios.
80 lines
3.4 KiB
Bash
Executable File
80 lines
3.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
CUSTOM_NODES="/data/config/comfy/custom_nodes"
|
|
mkdir -vp "${CUSTOM_NODES}"
|
|
|
|
declare -A MOUNTS
|
|
|
|
MOUNTS["${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}")
|
|
done
|
|
|
|
if [ "${UPDATE_CUSTOM_NODES:-false}" = "true" ]; then
|
|
find /data/config/comfy/custom_nodes/ -mindepth 1 -maxdepth 1 -type d | while read NODE
|
|
do echo "---- ${NODE##*/} ----"
|
|
cd $NODE && git pull; cd ..
|
|
done
|
|
fi
|
|
|
|
if [ "${USE_KRITA}" = "true" ]; then
|
|
if [ "${KRITA_DOWNLOAD_MODELS:-false}" = "true" ]; then
|
|
cd "${ROOT}/krita-ai-diffusion/scripts" && python download_models.py --verbose --retry-attempts 10 --continue-on-error --recommended /data && cd ..
|
|
fi
|
|
[ -d "${ROOT}/models/upscale_models" ] && mv -v "${ROOT}/models/upscale_models" "${ROOT}/models/upscale_models.stock"
|
|
if [ ! -L "${ROOT}/models/upscale_models" ]; then
|
|
cd "${ROOT}/models"
|
|
ln -sfT /data/models/upscale_models upscale_models
|
|
fi
|
|
export USE_CNAUX="true" USE_IPAPLUS="true" USE_INPAINT="true"; USE_TOOLING="true"
|
|
fi
|
|
if [ "${USE_GGUF}" = "true" ]; then
|
|
[ ! -e "${CUSTOM_NODES}/ComfyUI-GGUF" ] && mv "${ROOT}/ComfyUI-GGUF" "${CUSTOM_NODES}"/
|
|
fi
|
|
if [ "${USE_XFLUX}" = "true" ]; then
|
|
[ ! -e "${CUSTOM_NODES}/x-flux-comfyui" ] && mv "${ROOT}/x-flux-comfyui" "${CUSTOM_NODES}"/
|
|
[ ! -e "/data/models/clip_vision" ] && mkdir -p /data/models/clip_vision
|
|
[ ! -e "/data/models/clip_vision/model.safetensors" ] && cd /data/models/clip_vision && \
|
|
python -c 'import sys; from urllib.request import urlopen; from pathlib import Path; Path(sys.argv[2]).write_bytes(urlopen(sys.argv[1]).read())' \
|
|
"https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/model.safetensors" "model.safetensors"
|
|
[ ! -e "/data/models/xlabs" ] && mkdir -p /data/models/xlabs/{ipadapters,loras,controlnets}
|
|
[ ! -e "/data/models/xlabs/ipadapters/flux-ip-adapter.safetensors" ] && cd /data/models/xlabs/ipadapters && \
|
|
python -c 'import sys; from urllib.request import urlopen; from pathlib import Path; Path(sys.argv[2]).write_bytes(urlopen(sys.argv[1]).read())' \
|
|
"https://huggingface.co/XLabs-AI/flux-ip-adapter/resolve/main/ip_adapter.safetensors" "flux-ip-adapter.safetensors"
|
|
[ -d "${ROOT}/models/xlabs" ] && rm -rf "${ROOT}/models/xlabs"
|
|
[ ! -e "${ROOT}/models/xlabs" ] && cd "${ROOT}/models" && ln -sT /data/models/xlabs xlabs && cd ..
|
|
fi
|
|
if [ "${USE_CNAUX}" = "true" ]; then
|
|
[ ! -e "${CUSTOM_NODES}/comfyui_controlnet_aux" ] && mv "${ROOT}/comfyui_controlnet_aux" "${CUSTOM_NODES}"/
|
|
fi
|
|
if [ "${USE_IPAPLUS}" = "true" ]; then
|
|
[ ! -e "${CUSTOM_NODES}/ComfyUI_IPAdapter_plus" ] && mv "${ROOT}/ComfyUI_IPAdapter_plus" "${CUSTOM_NODES}"/
|
|
fi
|
|
if [ "${USE_INPAINT}" = "true" ]; then
|
|
[ ! -e "${CUSTOM_NODES}/comfyui-inpaint-nodes" ] && mv "${ROOT}/comfyui-inpaint-nodes" "${CUSTOM_NODES}"/
|
|
fi
|
|
if [ "${USE_TOOLING}" = "true" ]; then
|
|
[ ! -e "${CUSTOM_NODES}/comfyui-tooling-nodes" ] && mv "${ROOT}/comfyui-tooling-nodes" "${CUSTOM_NODES}"/
|
|
fi
|
|
|
|
if [ -f "/data/config/comfy/startup.sh" ]; then
|
|
pushd ${ROOT}
|
|
. /data/config/comfy/startup.sh
|
|
popd
|
|
fi
|
|
|
|
exec "$@"
|