forked from comfyanonymous/ComfyUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
80 lines (63 loc) · 2.38 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
ARG BASE_IMAGE="ubuntu:22.04"
FROM ${BASE_IMAGE}
ARG PYTORCH_INSTALL_ARGS=""
ARG EXTRA_ARGS=""
ARG USERNAME="comfyui"
ARG USER_UID=1000
ARG USER_GID=${USER_UID}
# Prevents prompts from packages asking for user input during installation
ENV DEBIAN_FRONTEND=noninteractive
# Prefer binary wheels over source distributions for faster pip installations
ENV PIP_PREFER_BINARY=1
# Ensures output from python is printed immediately to the terminal without buffering
ENV PYTHONUNBUFFERED=1
RUN \
--mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
python3.10 \
python3-pip \
python3-venv \
git \
wget \
git-lfs \
rsync \
ffmpeg \
libsm6 \
libxext6
# Clean up to reduce image size
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
RUN set -eux; \
groupadd --gid ${USER_GID} ${USERNAME}; \
useradd --uid ${USER_UID} --gid ${USER_GID} -m ${USERNAME}
# run instructions as user
USER ${USER_UID}:${USER_GID}
WORKDIR /workspace/ComfyUI
ENV PIP_CACHE_DIR="/cache/pip"
ENV VIRTUAL_ENV=/workspace/ComfyUI/venv
ENV VIRTUAL_ENV_CUSTOM=/workspace/ComfyUI/custom_venv
ENV TRANSFORMERS_CACHE="/workspace/ComfyUI/.cache/transformers"
# create cache directory
RUN mkdir -p ${TRANSFORMERS_CACHE}
# create virtual environment to manage packages
RUN python3 -m venv ${VIRTUAL_ENV}
# run python from venv
ENV PATH="${VIRTUAL_ENV_CUSTOM}/bin:${VIRTUAL_ENV}/bin:${PATH}"
RUN --mount=type=cache,target=/cache/,uid=${USER_UID},gid=${USER_GID} \
pip install torch torchvision torchaudio ${PYTORCH_INSTALL_ARGS}
# copy requirements files first so packages can be cached separately
COPY --chown=${USER_UID}:${USER_GID} requirements.txt .
RUN --mount=type=cache,target=/cache/,uid=${USER_UID},gid=${USER_GID} \
pip install -r requirements.txt
COPY --chown=${USER_UID}:${USER_GID} . .
RUN pip install -r custom_nodes/requirements_custom_nodes.txt
# default environment variables
ENV COMFYUI_ADDRESS=0.0.0.0
ENV COMFYUI_PORT=8188
ENV COMFYUI_EXTRA_BUILD_ARGS="${EXTRA_ARGS}"
ENV COMFYUI_EXTRA_ARGS=""
# default start command
CMD if [ -d "${VIRTUAL_ENV_CUSTOM}" ]; then rsync -aP "${VIRTUAL_ENV}/" "${VIRTUAL_ENV_CUSTOM}/"; fi;\
python3 -u main.py --listen ${COMFYUI_ADDRESS} --port ${COMFYUI_PORT} ${COMFYUI_EXTRA_BUILD_ARGS} ${COMFYUI_EXTRA_ARGS}