2024-11-17 20:12:20 -07:00
|
|
|
FROM pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime
|
2024-10-28 22:40:37 -06:00
|
|
|
|
2024-09-29 03:45:53 -06:00
|
|
|
# Limited system user UID
|
|
|
|
|
ARG USE_UID=991
|
|
|
|
|
# Limited system user GID
|
|
|
|
|
ARG USE_GID=991
|
2024-11-17 20:12:20 -07:00
|
|
|
# System user name
|
|
|
|
|
ARG USE_USER=app
|
|
|
|
|
# System group name
|
|
|
|
|
ARG USE_GROUP=app
|
2024-09-29 03:45:53 -06:00
|
|
|
# Latest tag or bleeding edge commit
|
|
|
|
|
ARG USE_EDGE=false
|
2024-10-28 22:40:37 -06:00
|
|
|
# ComfyUI-GGUF
|
2024-09-29 03:45:53 -06:00
|
|
|
ARG USE_GGUF=false
|
2024-10-28 22:40:37 -06:00
|
|
|
# x-flux-comfyui
|
2024-09-29 03:45:53 -06:00
|
|
|
ARG USE_XFLUX=false
|
2024-10-28 22:40:37 -06:00
|
|
|
# comfyui_controlnet_aux
|
2024-09-29 03:45:53 -06:00
|
|
|
ARG USE_CNAUX=false
|
2024-10-28 22:40:37 -06:00
|
|
|
# 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
|
2024-09-29 03:45:53 -06:00
|
|
|
|
2024-11-17 20:12:20 -07:00
|
|
|
# Support both root and non-root
|
|
|
|
|
RUN if [ ${USE_UID} -eq 0 ]; then SET_USER=root; else SET_USER=${USE_USER}; fi
|
|
|
|
|
RUN if [ ${USE_GID} -eq 0 ]; then SET_GROUP=root; else SET_GROUP=${USE_GROUP}; fi
|
|
|
|
|
ENV USE_USER=${SET_USER}
|
|
|
|
|
ENV USE_GROUP=${SET_GROUP}
|
|
|
|
|
|
2024-09-29 03:45:53 -06:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 USE_EDGE=$USE_EDGE
|
|
|
|
|
ENV USE_GGUF=$USE_GGUF USE_XFLUX=$USE_XFLUX ROOT=/stable-diffusion
|
2024-11-17 20:12:20 -07:00
|
|
|
ENV CACHE=/home/${USE_USER}/.cache USE_CNAUX=$USE_CNAUX USE_KRITA=$USE_KRITA
|
2024-10-28 22:40:37 -06:00
|
|
|
ENV USE_IPAPLUS=$USE_IPAPLUS USE_INPAINT=$USE_INPAINT USE_TOOLING=$USE_TOOLING
|
2024-09-29 03:45:53 -06:00
|
|
|
|
|
|
|
|
# User/Group
|
2024-11-17 20:12:20 -07:00
|
|
|
RUN if [ ${USE_GID} -ne 0 ]; then \
|
|
|
|
|
groupadd -r ${USE_GROUP} -g ${USE_GID}; \
|
|
|
|
|
fi; \
|
|
|
|
|
if [ ${USE_GID} -ne 0 ]; then \
|
|
|
|
|
useradd --no-log-init -m -r -g ${USE_GROUP} ${USE_USER} -u ${USE_UID}; \
|
|
|
|
|
fi; \
|
2024-09-29 03:45:53 -06:00
|
|
|
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}
|
|
|
|
|
|
2024-11-17 20:12:20 -07:00
|
|
|
RUN apt-get update && apt-get install -y git
|
|
|
|
|
RUN if [ "${USE_XFLUX}" = "true" ] || [ "${USE_KRITA}" = "true" ] || [ "${USE_CNAUX}" = "true" ]; then \
|
|
|
|
|
apt-get install -y libgl1-mesa-glx python3-opencv; \
|
|
|
|
|
fi
|
|
|
|
|
RUN apt-get clean
|
2024-09-29 03:45:53 -06:00
|
|
|
|
2024-11-17 20:12:20 -07:00
|
|
|
USER ${USE_USER}:${USE_GROUP}
|
|
|
|
|
ENV PATH="${PATH}:/home/${USE_USER}/.local/bin"
|
2023-04-21 12:34:17 -07:00
|
|
|
|
2024-09-29 03:45:53 -06:00
|
|
|
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} pip --cache-dir=${CACHE}/pip install -U pip
|
2023-04-21 12:34:17 -07:00
|
|
|
|
2024-09-29 03:45:53 -06:00
|
|
|
RUN --mount=type=cache,uid=${USE_UID},gid=${USE_GID},target=${CACHE} \
|
2023-04-21 12:34:17 -07:00
|
|
|
git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \
|
|
|
|
|
cd ${ROOT} && \
|
|
|
|
|
git checkout master && \
|
2024-09-29 03:45:53 -06:00
|
|
|
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 && \
|
2024-10-28 22:40:37 -06:00
|
|
|
if [ "${USE_KRITA}" = "true" ]; then \
|
2024-10-29 01:36:21 -06:00
|
|
|
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"; \
|
2024-10-28 22:40:37 -06:00
|
|
|
fi; \
|
2024-09-29 03:45:53 -06:00
|
|
|
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 && \
|
2024-10-28 22:40:37 -06:00
|
|
|
# This extra step to separate onnxruntime installation is required to restore onnx cuda support \
|
2024-09-29 03:45:53 -06:00
|
|
|
pip --cache-dir=${CACHE}/pip install onnxruntime && pip --cache-dir=${CACHE}/pip install onnxruntime-gpu && cd ..; \
|
2024-10-28 22:40:37 -06:00
|
|
|
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 && \
|
2024-10-29 01:36:21 -06:00
|
|
|
pip --cache-dir=${CACHE}/pip install opencv-python && cd ..; \
|
2024-10-28 22:40:37 -06:00
|
|
|
fi; \
|
|
|
|
|
if [ "${USE_TOOLING}" = "true" ]; then \
|
|
|
|
|
git clone https://github.com/Acly/comfyui-tooling-nodes.git && \
|
|
|
|
|
cd comfyui-tooling-nodes && git checkout main && cd ..; \
|
2024-09-29 03:45:53 -06:00
|
|
|
fi
|
2023-04-21 12:34:17 -07:00
|
|
|
|
|
|
|
|
WORKDIR ${ROOT}
|
2024-09-29 03:45:53 -06:00
|
|
|
COPY --chown=${USE_UID}:${USE_GID} . /docker/
|
2024-01-01 19:04:02 +09:00
|
|
|
RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml ${ROOT}
|
2023-04-21 12:34:17 -07:00
|
|
|
|
2024-01-01 19:04:02 +09:00
|
|
|
ENV NVIDIA_VISIBLE_DEVICES=all PYTHONPATH="${PYTHONPATH}:${PWD}" CLI_ARGS=""
|
2023-04-21 12:34:17 -07:00
|
|
|
EXPOSE 7860
|
|
|
|
|
ENTRYPOINT ["/docker/entrypoint.sh"]
|
|
|
|
|
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}
|