2025-04-29 05:15:00 +02:00
|
|
|
FROM pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime AS base
|
2023-04-21 21:34:17 +02:00
|
|
|
|
2025-04-28 22:05:02 +02:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
ENV PIP_PREFER_BINARY=1
|
2023-04-21 21:34:17 +02:00
|
|
|
|
2025-04-29 16:22:34 +02:00
|
|
|
RUN --mount=type=cache,target=/var/cache/apt \
|
|
|
|
|
apt-get update && \
|
2025-05-31 20:06:24 +02:00
|
|
|
apt-get install -y --no-install-recommends git wget curl jq ffmpeg libgl1-mesa-glx libglib2.0-0 && \
|
|
|
|
|
apt-get clean && \
|
|
|
|
|
pip install --no-input --upgrade pip
|
2025-04-28 23:47:23 +02:00
|
|
|
|
2025-04-29 05:15:00 +02:00
|
|
|
FROM base AS application
|
|
|
|
|
|
|
|
|
|
RUN useradd -m -s /bin/bash comfy
|
|
|
|
|
|
|
|
|
|
USER comfy
|
2023-04-21 21:34:17 +02:00
|
|
|
|
2025-04-29 05:15:00 +02:00
|
|
|
WORKDIR /home/comfy/app
|
2025-04-28 19:42:47 +02:00
|
|
|
|
2025-05-31 20:06:24 +02:00
|
|
|
SHELL ["/bin/bash", "--login", "-c"]
|
|
|
|
|
|
|
|
|
|
# Setup ComfyUI project
|
|
|
|
|
RUN git clone --branch v0.3.39 --depth 1 https://github.com/comfyanonymous/ComfyUI.git .
|
2025-04-29 05:15:00 +02:00
|
|
|
|
|
|
|
|
COPY --chown=comfy:comfy . .
|
|
|
|
|
|
2025-05-31 20:06:24 +02:00
|
|
|
# Setup venv
|
|
|
|
|
# # https://pythonspeed.com/articles/activate-virtualenv-dockerfile/
|
|
|
|
|
ENV VIRTUAL_ENV=/home/comfy/app/.venv
|
|
|
|
|
RUN --mount=type=cache,target=~/.cache/pip \
|
|
|
|
|
mkdir -p ~/.local/bin && \
|
|
|
|
|
python -m venv $VIRTUAL_ENV
|
2025-04-29 05:15:00 +02:00
|
|
|
|
2025-05-31 20:06:24 +02:00
|
|
|
ENV PATH="/home/comfy/.local/bin:$PATH"
|
|
|
|
|
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
|
|
|
# ENV PYTHONPATH="${PYTHONPATH}:${PWD}"
|
|
|
|
|
|
|
|
|
|
# Activate environment and install dependencies
|
|
|
|
|
# Should make ONNX optional by moving this into a configuration file that can be alterated at run time
|
|
|
|
|
RUN --mount=type=cache,target=~/.cache/pip \
|
|
|
|
|
pip install -r requirements.txt && \
|
|
|
|
|
pip install onnxruntime-gpu && \
|
|
|
|
|
chmod u+x ./entrypoint.sh
|
2025-04-29 05:15:00 +02:00
|
|
|
|
|
|
|
|
ENV NVIDIA_VISIBLE_DEVICES=all
|
|
|
|
|
ENV CLI_ARGS=""
|
2023-04-21 21:34:17 +02:00
|
|
|
|
2025-05-31 20:06:24 +02:00
|
|
|
EXPOSE 8188
|
2025-04-28 22:05:02 +02:00
|
|
|
|
|
|
|
|
ENTRYPOINT ["./entrypoint.sh"]
|
2025-05-31 20:06:24 +02:00
|
|
|
CMD python -u main.py --listen --port 8188 ${CLI_ARGS}
|
|
|
|
|
|
|
|
|
|
# Explore how we can use the CLI to do this instead
|
|
|
|
|
# https://docs.comfy.org/installation/system_requirements
|
|
|
|
|
# https://docs.comfy.org/comfy-cli/getting-started
|
|
|
|
|
# https://pythonspeed.com/articles/activate-conda-dockerfile/
|
|
|
|
|
# https://pythonspeed.com/articles/multi-stage-docker-python/
|
|
|
|
|
# pip install comfy-cli && \
|
|
|
|
|
# comfy install
|