| 
									
										
										
										
											2024-10-28 22:40:37 -06:00
										 |  |  | FROM pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-29 03:45:53 -06:00
										 |  |  | # 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 | 
					
						
							| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | 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-10-28 22:40:37 -06:00
										 |  |  | 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
 | 
					
						
							| 
									
										
										
										
											2024-09-29 03:45:53 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | # 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"
 | 
					
						
							| 
									
										
										
										
											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 \
 | 
					
						
							|  |  |  |     USE_CNAUX="true"; USE_IPAPLUS="true"; \
 | 
					
						
							|  |  |  |     USE_INPAINT="true"; USE_TOOLING="true"; \
 | 
					
						
							|  |  |  |   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 && \
 | 
					
						
							|  |  |  |     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 ..; \
 | 
					
						
							| 
									
										
										
										
											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}
 |