Skip to content

Commit

Permalink
feat(comfy-ui): more user-friendly starting/saving scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
tinovyatkin committed Jan 21, 2025
1 parent 2a8e411 commit deac2ed
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 12 deletions.
14 changes: 3 additions & 11 deletions ComfyUI/DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,12 @@ 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
./start-dev-container.sh
```

## Getting changes from the container
## Stopping and saving changes from the container

```sh
git add --all
git commit -m 'Getting all my changes'
git archive -o update.zip HEAD $(git diff --submodule=diff --name-only HEAD HEAD^)
save-and-stop-dev-container.sh
```

18 changes: 17 additions & 1 deletion ComfyUI/Dockerfile.local-cpu
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,24 @@ skip_migration_check = True
model_download_by_agent = False
EOF

# create changeset saving script
RUN mkdir changeset
RUN <<EOF cat >> save-changeset.sh
#!/bin/bash
git add --all
git commit -m 'All changes'
git archive -o changeset/update.tar.gz HEAD
EOF
RUN chmod +x save-changeset.sh
RUN echo "save-changeset.sh" >> .gitignore
RUN echo "changeset/" >> .gitignore


# commit current state so we can trace changes
RUN git add . && git commit -m "chore: initial setup" && git checkout -b container/dev
RUN git add . \
&& git commit -m "chore: initial setup" \
&& git checkout -b container/dev \
&& git tag -a start -m "start"

# Expose the port the ComfyUI runs on
EXPOSE 8188
Expand Down
13 changes: 13 additions & 0 deletions ComfyUI/save-and-stop-dev-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# create a ComfyUI Manager snapshot
curl -H 'Comfy-User;' http://localhost:8188/api/snapshot/save

# run the script
docker exec comfyui /opt/ComfyUI/save-changeset.sh

# stop the container
docker stop comfyui

# show the folder with changeset
npx -y -q opener ./changeset
23 changes: 23 additions & 0 deletions ComfyUI/start-dev-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

# Ensure local folders exists
mkdir -p models changeset snapshots

# Start the dev container with folder mounts
docker run -d \
-it \
--name comfyui \
--publish 8188:8188 \
--mount type=bind,source="$(pwd)"/models,target=/opt/ComfyUI/models \
--mount type=bind,source="$(pwd)"/changeset,target=/opt/ComfyUI/changeset \
--mount type=bind,source="$(pwd)"/snapshots,target=/opt/ComfyUI/user/default/ComfyUI-Manager/snapshots/ \
comfyui

echo Waiting for ComfyUI to start...
until curl --output /dev/null --silent --head --fail http://localhost:8188; do
printf '.'
sleep 1
done
npx -y -q opener http://localhost:8188

0 comments on commit deac2ed

Please sign in to comment.