mirror of
https://github.com/AbdBarho/stable-diffusion-webui-docker.git
synced 2025-10-26 15:54:17 -04:00
96 lines
4.1 KiB
Docker
96 lines
4.1 KiB
Docker
FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
|
|
|
|
# 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
|
|
ARG USE_GGUF=false
|
|
# x-flux-comfyui
|
|
ARG USE_XFLUX=false
|
|
# comfyui_controlnet_aux
|
|
ARG USE_CNAUX=false
|
|
# krita-ai-diffusion
|
|
ARG USE_KRITA=false
|
|
# ComfyUI_IPAdapter_plus
|
|
ARG USE_IPAPLUS=false
|
|
# comfyui-inpaint-nodes
|
|
ARG USE_INPAINT=false
|
|
# comfyui-tooling-nodes
|
|
ARG USE_TOOLING=false
|
|
|
|
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 USE_KRITA=$USE_KRITA
|
|
ENV USE_IPAPLUS=$USE_IPAPLUS USE_INPAINT=$USE_INPAINT USE_TOOLING=$USE_TOOLING
|
|
|
|
# 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" || "${USE_KRITA}" == "true" || "${USE_CNAUX}" == "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_KRITA}" = "true" ]; then \
|
|
pip --cache-dir=${CACHE}/pip install aiohttp tqdm && \
|
|
git clone https://github.com/Acly/krita-ai-diffusion.git && \
|
|
cd krita-ai-diffusion && git checkout main && \
|
|
git submodule update --init && cd ..; \
|
|
export USE_CNAUX="true" USE_IPAPLUS="true" \
|
|
USE_INPAINT="true" USE_TOOLING="true"; \
|
|
fi; \
|
|
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; \
|
|
if [ "${USE_IPAPLUS}" = "true" ]; then \
|
|
git clone https://github.com/cubiq/ComfyUI_IPAdapter_plus.git && \
|
|
cd ComfyUI_IPAdapter_plus && git checkout main && cd ..; \
|
|
fi; \
|
|
if [ "${USE_INPAINT}" = "true" ]; then \
|
|
git clone https://github.com/Acly/comfyui-inpaint-nodes.git && \
|
|
cd comfyui-inpaint-nodes && git checkout main && \
|
|
pip --cache-dir=${CACHE}/pip install opencv-python && cd ..; \
|
|
fi; \
|
|
if [ "${USE_TOOLING}" = "true" ]; then \
|
|
git clone https://github.com/Acly/comfyui-tooling-nodes.git && \
|
|
cd comfyui-tooling-nodes && git checkout main && 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}
|