-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(comfy-ui): create developing image #79
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ed97125
feat(comfy-ui): create base developing image
tinovyatkin e156bf1
chore: make venv relocatable
tinovyatkin 3cc43a5
chore: add trailing new line to dockerfile
tinovyatkin 38985b1
feat: add Github Action to build ComfyUI dev container
tinovyatkin 7a35039
docs: add diff commands
tinovyatkin 7b86882
chore: edit existing gitignore and pre-create branch
tinovyatkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Building developing image | ||
|
||
```sh | ||
docker buildx build -f Dockerfile.local-cpu -t comfyui . | ||
``` | ||
|
||
## Running the container | ||
|
||
```sh | ||
docker run \ | ||
--name comfyui \ | ||
--publish 8188:8188 \ | ||
# optionally to run in background | ||
--detach \ | ||
--restart unless-stopped \ | ||
comfyui | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# syntax = docker/dockerfile:1.4.0 | ||
# Use a Python image with uv pre-installed | ||
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim | ||
|
||
# The installer requires curl (and certificates) to download the release archive | ||
RUN --mount=type=cache,target=/var/cache/apt,rw --mount=type=cache,target=/var/lib/apt,rw \ | ||
apt-get update && apt-get install -y --no-install-recommends \ | ||
git \ | ||
git-lfs \ | ||
build-essential \ | ||
libgl1-mesa-glx \ | ||
wget \ | ||
curl \ | ||
unzip \ | ||
ffmpeg | ||
|
||
# Enable bytecode compilation | ||
ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy | ||
|
||
# Set environment variables | ||
ARG COMFYUI_VERSION=v0.3.10 | ||
ARG COMFYUI_MANAGER_VERSION=3.6.5 | ||
ENV PYTHONUNBUFFERED=1 \ | ||
COMFYUI_REPO=https://github.com/comfyanonymous/ComfyUI.git \ | ||
COMFYUI_MANAGER_REPO=https://github.com/ltdrdata/ComfyUI-Manager.git \ | ||
COMFYUI_DIR=/opt/ComfyUI | ||
|
||
# Clones the ComfyUI repository and checks out the latest release | ||
# Clone the ComfyUI repository | ||
RUN git clone --branch $COMFYUI_VERSION --single-branch $COMFYUI_REPO $COMFYUI_DIR | ||
|
||
# Change into ComfyUI directory | ||
WORKDIR $COMFYUI_DIR | ||
|
||
RUN git config --local user.email "[email protected]" \ | ||
&& git config --global user.name "Container Builder" | ||
|
||
# Create Python virtual environment | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv venv --seed --relocatable .venv | ||
ENV VIRTUAL_ENV=$COMFYUI_DIR/.venv | ||
ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
||
# Install PyTorch and its dependencies | ||
# see https://docs.astral.sh/uv/guides/integration/pytorch/#the-uv-pip-interface | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | ||
|
||
# Install the required Python packages for ComfyUI | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv pip install -r requirements.txt | ||
Comment on lines
+49
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Verify package integrity during installation. Add hash verification for better security: RUN --mount=type=cache,target=/root/.cache/uv \
- uv pip install -r requirements.txt
+ uv pip install -r requirements.txt --require-hashes Generate requirements with hashes using: uv pip freeze --all --require-hashes > requirements.txt |
||
|
||
# Clones the ComfyUI Manager repository and checks out the latest release | ||
# remove gitignore to allow adding submodule into custom_nodes | ||
RUN rm .gitignore | ||
tinovyatkin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
RUN git submodule add $COMFYUI_MANAGER_REPO custom_nodes/ComfyUI-Manager \ | ||
&& cd custom_nodes/ComfyUI-Manager \ | ||
&& git checkout tags/$COMFYUI_MANAGER_VERSION | ||
RUN --mount=type=cache,target=/root/.cache/uv \ | ||
uv pip install -r custom_nodes/ComfyUI-Manager/requirements.txt | ||
|
||
# Creating ComfyUI Manager config file | ||
RUN mkdir -p user/default/ComfyUI-Manager | ||
RUN <<EOF cat >> user/default/ComfyUI-Manager/config.ini | ||
[default] | ||
preview_method = auto | ||
file_logging = False | ||
security_level = weak | ||
skip_migration_check = True | ||
model_download_by_agent = False | ||
EOF | ||
marchuk-vlad marked this conversation as resolved.
Show resolved
Hide resolved
tinovyatkin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# commit current state so we can trace changes | ||
RUN git add . && git commit -m "chore: initial setup" | ||
|
||
# Expose the port the ComfyUI runs on | ||
EXPOSE 8188 | ||
|
||
# Add a healthcheck to ensure the service is running | ||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ | ||
CMD curl -f http://localhost:8188/ || exit 1 | ||
|
||
# On startup, ComfyUI is started at its default port; the IP address is changed from localhost to 0.0.0.0, because Docker is only forwarding traffic | ||
# to the IP address it assigns to the container, which is unknown at build time; listening to 0.0.0.0 means that ComfyUI listens to all incoming | ||
# traffic; the auto-launch feature is disabled, because we do not want (nor is it possible) to open a browser window in a Docker container | ||
CMD [".venv/bin/python", "main.py", "--listen", "0.0.0.0", "--port", "8188", "--disable-auto-launch", "--cpu", "--cpu-vae"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to install these libraries separately? Isn't the requirements.txt file in the ComfyUI root directory sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requirements.txt
is not enough in case of GPU optimized versions pytorch as it ships different builds using different indexes.See https://docs.astral.sh/uv/guides/integration/pytorch/