mirror of
https://github.com/AbdBarho/stable-diffusion-webui-docker.git
synced 2025-10-27 08:14:26 -04:00
- Non-root default - Use `git describe` to automatically use latest ComfyUI tag (or `USE_EDGE=true` variable for latest commit) - Support custom_nodes: * **ComfyUI-GGUF support** (`USE_GGUF=true`) * **x-flux-comfyui support** (`USE_XFLUX=true`) * **comfyui_controlnet_aux support** (`USE_CNAUX=false`)
74 lines
2.9 KiB
Docker
74 lines
2.9 KiB
Docker
# Limited system user UID
|
|
ARG USE_UID=991
|
|
# Limited system user GID
|
|
ARG USE_GID=991
|
|
# Latest tag or bleeding edge commit
|
|
ARG USE_EDGE=false
|
|
# ComfyUI-GGUF support
|
|
ARG USE_GGUF=false
|
|
# x-flux-comfyui support
|
|
ARG USE_XFLUX=false
|
|
# comfyui_controlnet_aux support
|
|
ARG USE_CNAUX=false
|
|
|
|
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime
|
|
|
|
# Use args
|
|
ARG USE_UID
|
|
ARG USE_GID
|
|
ARG USE_EDGE
|
|
ARG USE_GGUF
|
|
ARG USE_XFLUX
|
|
ARG USE_CNAUX
|
|
|
|
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 USE_EDGE=$USE_EDGE
|
|
ENV USE_GGUF=$USE_GGUF USE_XFLUX=$USE_XFLUX ROOT=/stable-diffusion
|
|
ENV CACHE=/home/app/.cache USE_CNAUX=$USE_CNAUX
|
|
|
|
# User/Group
|
|
RUN groupadd -r app -g ${USE_GID} && useradd --no-log-init -m -r -g app app -u ${USE_UID} && \
|
|
mkdir -p ${ROOT} && chown ${USE_UID}:${USE_GID} ${ROOT} && mkdir -p ${CACHE}/pip && chown -R ${USE_UID}:${USE_GID} ${CACHE}
|
|
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} chown -R ${USE_UID}:${USE_UID} ${CACHE}
|
|
|
|
RUN apt-get update && apt-get install -y git && ([ "${USE_XFLUX}" = "true" ] && apt-get install -y libgl1-mesa-glx python3-opencv) && apt-get clean
|
|
|
|
USER app:app
|
|
ENV PATH="${PATH}:/home/app/.local/bin"
|
|
|
|
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} pip --cache-dir=${CACHE}/pip install -U pip
|
|
|
|
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} \
|
|
git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \
|
|
cd ${ROOT} && \
|
|
git checkout master && \
|
|
bash -c 'VERSION=$(git describe --tags --abbrev=0) && \
|
|
if [ "${USE_EDGE}" = "true" ]; then VERSION=$(git describe --abbrev=7); fi && \
|
|
git reset --hard ${VERSION}' && \
|
|
pip --cache-dir=${CACHE}/pip install -r requirements.txt && \
|
|
if [ "${USE_GGUF}" = "true" ]; then \
|
|
git clone https://github.com/city96/ComfyUI-GGUF.git && \
|
|
cd ComfyUI-GGUF && git checkout main && \
|
|
pip --cache-dir=${CACHE}/pip install -r requirements.txt && cd ..; \
|
|
fi; \
|
|
if [ "${USE_XFLUX}" = "true" ]; then \
|
|
git clone https://github.com/XLabs-AI/x-flux-comfyui.git && \
|
|
cd x-flux-comfyui && git checkout main && \
|
|
pip --cache-dir=${CACHE}/pip install -r requirements.txt && cd ..; \
|
|
fi; \
|
|
if [ "${USE_CNAUX}" = "true" ]; then \
|
|
git clone https://github.com/Fannovel16/comfyui_controlnet_aux.git && \
|
|
cd comfyui_controlnet_aux && git checkout main && \
|
|
pip --cache-dir=${CACHE}/pip install -r requirements.txt && \
|
|
# This extra step to separate onnxruntime installation is required to restore onnx cuda support
|
|
pip --cache-dir=${CACHE}/pip install onnxruntime && pip --cache-dir=${CACHE}/pip install onnxruntime-gpu && cd ..; \
|
|
fi
|
|
|
|
WORKDIR ${ROOT}
|
|
COPY --chown=${USE_UID}:${USE_GID} . /docker/
|
|
RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml ${ROOT}
|
|
|
|
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}
|