Improve docker configuration (#4)

Improve docker configuration
This commit is contained in:
Brian Gebel 2025-05-31 11:06:24 -07:00 committed by GitHub
parent 541965b37c
commit 0eee719776
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 127 additions and 161 deletions

View file

@ -5,12 +5,10 @@ ENV PIP_PREFER_BINARY=1
RUN --mount=type=cache,target=/var/cache/apt \
apt-get update && \
apt-get install -y git wget curl jq ffmpeg libgl1-mesa-glx libglib2.0-0 && \
apt-get clean
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
# 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
FROM base AS application
RUN useradd -m -s /bin/bash comfy
@ -19,31 +17,43 @@ USER comfy
WORKDIR /home/comfy/app
# Using CLI (with conda venv -can do venv without all this too)
# python -m pip install -U pip && \
# pip install comfy-cli && \
# conda init bash && \
# conda create -n comfy-env python=3.11 && \
# conda activate comfy-env && \
# comfy install
RUN --mount=type=cache,target=/comfy/.cache/pip \
git clone --branch v0.3.30 --depth 1 https://github.com/comfyanonymous/ComfyUI.git . && \
mkdir -p .local/bin && \
pip install -r requirements.txt && \
pip install onnxruntime-gpu
# Should make ONNX optional by moving this into a configuration file that can be alterated at run time
SHELL ["/bin/bash", "--login", "-c"]
# Setup ComfyUI project
RUN git clone --branch v0.3.39 --depth 1 https://github.com/comfyanonymous/ComfyUI.git .
COPY --chown=comfy:comfy . .
RUN chmod u+x ./entrypoint.sh
# 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
ENV PATH="/home/comfy/.local/bin:${PATH}"
ENV PYTHONPATH="${PYTHONPATH}:${PWD}"
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
ENV NVIDIA_VISIBLE_DEVICES=all
ENV CLI_ARGS=""
EXPOSE 7860
EXPOSE 8188
ENTRYPOINT ["./entrypoint.sh"]
CMD python -u main.py --listen --port 7860 ${CLI_ARGS}
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

View file

@ -3,27 +3,25 @@
set -Eeuo pipefail
BASE_DIRECTORY="/data/config/comfy"
OUTPUT_DIRECTORY="/data/output"
OUTPUT_DIRECTORY="/output"
mkdir -vp ${BASE_DIRECTORY}
mkdir -vp ${BASE_DIRECTORY}
mkdir -vp ${BASE_DIRECTORY}/temp
mkdir -vp ${BASE_DIRECTORY}/user
mkdir -vp ${BASE_DIRECTORY}/custom_nodes
mkdir -vp ${OUTPUT_DIRECTORY}
# @brian - Why is this here?
# XDG_CACHE_HOME - Set cache outside container
mkdir -vp /data/.cache
XDG_CACHE_HOME=/data/.cache
export XDG_CACHE_HOME
# mkdir -vp /data/.cache
# XDG_CACHE_HOME=/data/.cache
# export XDG_CACHE_HOME
# --base-directory BASE_DIRECTORY
# Set the ComfyUI base directory for models,
# custom_nodes, input, output, temp, and user directories.
CLI_ARGS+="${CLI_ARGS} --base-directory ${BASE_DIRECTORY} --output-directory ${OUTPUT_DIRECTORY}"
echo ${CLI_ARGS}
if [ -f "/data/config/comfy/startup.sh" ]; then
pushd ${APPLICATION_ROOT}
. /data/config/comfy/startup.sh

View file

@ -1,11 +1,14 @@
# https://github.com/comfyanonymous/ComfyUI/blob/master/extra_model_paths.yaml.example
# https://comfyui-wiki.com/en/tutorial/basic/link-models-between-comfyui-and-a1111
a111:
base_path: /data
checkpoints: models/Stable-diffusion
configs: models/Stable-diffusion
vae: models/VAE
loras: models/Lora
loras: |
models/Lora
models/LyCORIS
upscale_models: |
models/RealESRGAN
models/ESRGAN
@ -20,16 +23,20 @@ a111:
comfyui:
base_path: /data
# custom_nodes: config/comfy/custom_nodes
custom_nodes: config/comfy/custom_nodes
download_model_base: data/models
# TODO: I am unsure about these, need more testing
# style_models: data/config/comfy/style_models
# t2i_adapter: data/config/comfy/t2i_adapter
# clip_vision: data/config/comfy/clip_vision
# diffusers: data/config/comfy/diffusers
# download_model_base: data/models
# Need this file to be loaded dynamically maybe as a vol?
# Need to install ipadapter and set mappings
# https://github.com/cubiq/ComfyUI_IPAdapter_plus
# Create an auto installer? Is there a newer plugin/extension?
# Need this file to be loaded dynamically maybe as a vol? Currently these are being downloaded to /data/config/comfy/models
# - `ultralytics_bbox` - Specifies the paths for bbox YOLO models.
# - `ultralytics_segm` - Specifies the paths for segm YOLO models.
# - `ultralytics` - Allows the presence of `bbox/` and `segm/` subdirectories.

View file

@ -0,0 +1 @@
https://github.com/microsoft/TRELLIS/issues/14