docker v5: boot refresh mirrors workflows/ from the repo (refresh-workspace.sh), claude alias (IS_SANDBOX=1 --dangerously-skip-permissions); document interim v4 (no auto-start, script refresh)
Browse files- docker/Dockerfile +28 -13
- docker/README.md +29 -11
- docker/bash_aliases +3 -0
- docker/refresh-workspace.sh +68 -0
- docker/start-comfy.sh +10 -6
docker/Dockerfile
CHANGED
|
@@ -2,23 +2,32 @@
|
|
| 2 |
#
|
| 3 |
# NOTE: published plx1029/comfyui-qwen tags were NOT built from this file — they
|
| 4 |
# were assembled daemonlessly (v1: crane append on the pod; v2: skopeo + umoci;
|
| 5 |
-
# v3: crane append of a /workspace layer on top of v2
|
| 6 |
-
#
|
| 7 |
-
# same setup.
|
| 8 |
#
|
| 9 |
# Build from the REPO ROOT (context needs download_missing_models.sh + workflows/):
|
| 10 |
-
# docker build -t plx1029/comfyui-qwen:
|
| 11 |
-
# docker push plx1029/comfyui-qwen:
|
| 12 |
#
|
| 13 |
# No secrets are baked into this image (it is public). The model-download
|
| 14 |
# script prompts for your Hugging Face token at runtime (or reads $HF_TOKEN).
|
| 15 |
#
|
| 16 |
# v3: EVERYTHING lives in /workspace — /workspace/ComfyUI, /workspace/workflows,
|
| 17 |
-
# /workspace/download_missing_models.sh
|
| 18 |
-
#
|
| 19 |
-
#
|
| 20 |
-
#
|
| 21 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
FROM runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404
|
| 24 |
|
|
@@ -50,6 +59,10 @@ RUN curl -fsSL https://claude.ai/install.sh | bash && \
|
|
| 50 |
printf '{\n "bypassPermissionsModeAccepted": true\n}\n' > /root/.claude.json
|
| 51 |
ENV PATH="/root/.local/bin:${PATH}"
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
# Manager config baked in: security_level=weak, network_mode=personal_cloud
|
| 54 |
COPY docker/config.ini /workspace/ComfyUI/user/__manager/config.ini
|
| 55 |
COPY docker/comfy.settings.json /workspace/ComfyUI/user/default/comfy.settings.json
|
|
@@ -67,12 +80,14 @@ RUN chmod +x /workspace/download_missing_models.sh && \
|
|
| 67 |
# Seed tarball: restores /workspace when a network volume shadows it
|
| 68 |
RUN tar -czf /opt/workspace-seed.tar.gz -C /workspace ComfyUI workflows download_missing_models.sh
|
| 69 |
|
| 70 |
-
# Startup: seed /workspace if needed,
|
| 71 |
-
#
|
|
|
|
| 72 |
COPY docker/seed-workspace.sh /usr/local/bin/seed-workspace.sh
|
|
|
|
| 73 |
COPY docker/comfy /usr/local/bin/comfy
|
| 74 |
COPY docker/start-comfy.sh /start-comfy.sh
|
| 75 |
-
RUN chmod +x /usr/local/bin/comfy /usr/local/bin/seed-workspace.sh /start-comfy.sh
|
| 76 |
|
| 77 |
EXPOSE 7865
|
| 78 |
CMD ["/start-comfy.sh"]
|
|
|
|
| 2 |
#
|
| 3 |
# NOTE: published plx1029/comfyui-qwen tags were NOT built from this file — they
|
| 4 |
# were assembled daemonlessly (v1: crane append on the pod; v2: skopeo + umoci;
|
| 5 |
+
# v3: crane append of a /workspace layer on top of v2; v4 and v5: further
|
| 6 |
+
# crane appends). This Dockerfile is the reproducible equivalent: building it
|
| 7 |
+
# on any machine with Docker produces the same setup.
|
| 8 |
#
|
| 9 |
# Build from the REPO ROOT (context needs download_missing_models.sh + workflows/):
|
| 10 |
+
# docker build -t plx1029/comfyui-qwen:v5 -f docker/Dockerfile .
|
| 11 |
+
# docker push plx1029/comfyui-qwen:v5
|
| 12 |
#
|
| 13 |
# No secrets are baked into this image (it is public). The model-download
|
| 14 |
# script prompts for your Hugging Face token at runtime (or reads $HF_TOKEN).
|
| 15 |
#
|
| 16 |
# v3: EVERYTHING lives in /workspace — /workspace/ComfyUI, /workspace/workflows,
|
| 17 |
+
# /workspace/download_missing_models.sh. A compressed seed of the /workspace
|
| 18 |
+
# payload is kept at /opt/workspace-seed.tar.gz so that when a network volume
|
| 19 |
+
# is mounted over /workspace (shadowing the baked files), seed-workspace.sh
|
| 20 |
+
# restores the missing pieces without touching anything already on the volume.
|
| 21 |
+
#
|
| 22 |
+
# v4: ComfyUI no longer auto-starts (COMFY_AUTOSTART=true re-enables);
|
| 23 |
+
# download_missing_models.sh + README.md are re-fetched from the HF repo at
|
| 24 |
+
# boot.
|
| 25 |
+
#
|
| 26 |
+
# v5: the boot refresh lives in refresh-workspace.sh and now also MIRRORS
|
| 27 |
+
# workflows/ from hf.co/aleph65/ComfyUI (deletions included; uses
|
| 28 |
+
# HUGGING_FACE_ACCESS_TOKEN or HF_TOKEN if set; WORKSPACE_REFRESH=false
|
| 29 |
+
# disables). Also: interactive `claude` is aliased to
|
| 30 |
+
# `IS_SANDBOX=1 claude --dangerously-skip-permissions`.
|
| 31 |
|
| 32 |
FROM runpod/pytorch:1.0.2-cu1281-torch280-ubuntu2404
|
| 33 |
|
|
|
|
| 59 |
printf '{\n "bypassPermissionsModeAccepted": true\n}\n' > /root/.claude.json
|
| 60 |
ENV PATH="/root/.local/bin:${PATH}"
|
| 61 |
|
| 62 |
+
# Interactive shells: `claude` always runs sandboxed with permissions skipped
|
| 63 |
+
# (/root/.bashrc from the base image sources ~/.bash_aliases when present)
|
| 64 |
+
COPY docker/bash_aliases /root/.bash_aliases
|
| 65 |
+
|
| 66 |
# Manager config baked in: security_level=weak, network_mode=personal_cloud
|
| 67 |
COPY docker/config.ini /workspace/ComfyUI/user/__manager/config.ini
|
| 68 |
COPY docker/comfy.settings.json /workspace/ComfyUI/user/default/comfy.settings.json
|
|
|
|
| 80 |
# Seed tarball: restores /workspace when a network volume shadows it
|
| 81 |
RUN tar -czf /opt/workspace-seed.tar.gz -C /workspace ComfyUI workflows download_missing_models.sh
|
| 82 |
|
| 83 |
+
# Startup: seed /workspace if needed, refresh workflows + downloader from the
|
| 84 |
+
# HF repo (v5). ComfyUI does NOT auto-start (v4 default) — run `comfy`
|
| 85 |
+
# manually or set COMFY_AUTOSTART=true in the pod env.
|
| 86 |
COPY docker/seed-workspace.sh /usr/local/bin/seed-workspace.sh
|
| 87 |
+
COPY docker/refresh-workspace.sh /usr/local/bin/refresh-workspace.sh
|
| 88 |
COPY docker/comfy /usr/local/bin/comfy
|
| 89 |
COPY docker/start-comfy.sh /start-comfy.sh
|
| 90 |
+
RUN chmod +x /usr/local/bin/comfy /usr/local/bin/seed-workspace.sh /usr/local/bin/refresh-workspace.sh /start-comfy.sh
|
| 91 |
|
| 92 |
EXPOSE 7865
|
| 93 |
CMD ["/start-comfy.sh"]
|
docker/README.md
CHANGED
|
@@ -11,8 +11,16 @@ Everything from the manual setup is baked in — **no reinstalling on new pods**
|
|
| 11 |
- **`/workspace/download_missing_models.sh`** — pick workflows, it fetches their
|
| 12 |
missing models from `hf.co/aleph65/ComfyUI` into place (prompts for HF token
|
| 13 |
or reads `$HF_TOKEN`); still on PATH via symlink
|
| 14 |
-
- **
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
- rgthree-comfy @ `27b4f4c` in `custom_nodes/`
|
| 17 |
- comfyui-manager 4.2.2 + all pip deps preinstalled system-wide
|
| 18 |
- Manager config baked: `security_level = weak`, `network_mode = personal_cloud`
|
|
@@ -35,14 +43,17 @@ and outputs already on the volume are untouched.
|
|
| 35 |
|
| 36 |
## Using it on RunPod
|
| 37 |
|
| 38 |
-
1. Create a template with container image `plx1029/comfyui-qwen:
|
| 39 |
2. Expose HTTP port **7865** (plus 8888/22 as usual).
|
| 40 |
-
3.
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
`COMFY_PORT` overrides the port. `COMFY_AUTOSTART=
|
| 45 |
-
(
|
|
|
|
| 46 |
|
| 47 |
## How the image was built
|
| 48 |
|
|
@@ -52,13 +63,20 @@ assembled daemonlessly: v1 with [`crane`](https://github.com/google/go-container
|
|
| 52 |
**v3 with `crane append`** — a single layer holding `/workspace` (ComfyUI +
|
| 53 |
workflows + downloader), the seed tarball, the new startup scripts, and a
|
| 54 |
whiteout of the old `/ComfyUI`, appended on top of v2 (the ~11 GB base is never
|
| 55 |
-
re-uploaded)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
`Dockerfile` in this directory is the reproducible equivalent for rebuilding on
|
| 58 |
any machine with real Docker (build from the repo root — the context needs
|
| 59 |
`download_missing_models.sh` and `workflows/`):
|
| 60 |
|
| 61 |
```bash
|
| 62 |
-
docker build -t plx1029/comfyui-qwen:
|
| 63 |
-
docker push plx1029/comfyui-qwen:
|
| 64 |
```
|
|
|
|
| 11 |
- **`/workspace/download_missing_models.sh`** — pick workflows, it fetches their
|
| 12 |
missing models from `hf.co/aleph65/ComfyUI` into place (prompts for HF token
|
| 13 |
or reads `$HF_TOKEN`); still on PATH via symlink
|
| 14 |
+
- **v4: ComfyUI does NOT auto-start** (was the default in v3). Run `comfy` in a
|
| 15 |
+
terminal, or set `COMFY_AUTOSTART=true` in the pod env to re-enable
|
| 16 |
+
(port **7865**, log `/workspace/comfyui.log`, auto-restart loop).
|
| 17 |
+
- **v5: fresh workflows + downloader on every boot** — `refresh-workspace.sh`
|
| 18 |
+
re-pulls `workflows/` (mirrored, deletions included),
|
| 19 |
+
`download_missing_models.sh`, and `README.md` from `hf.co/aleph65/ComfyUI` at
|
| 20 |
+
startup, using `HUGGING_FACE_ACCESS_TOKEN`/`HF_TOKEN` if set. On any failure
|
| 21 |
+
the existing copies stay. Set `WORKSPACE_REFRESH=false` to disable.
|
| 22 |
+
- **v5: `claude` alias** — in interactive shells `claude` runs
|
| 23 |
+
`IS_SANDBOX=1 claude --dangerously-skip-permissions` (via `/root/.bash_aliases`).
|
| 24 |
- rgthree-comfy @ `27b4f4c` in `custom_nodes/`
|
| 25 |
- comfyui-manager 4.2.2 + all pip deps preinstalled system-wide
|
| 26 |
- Manager config baked: `security_level = weak`, `network_mode = personal_cloud`
|
|
|
|
| 43 |
|
| 44 |
## Using it on RunPod
|
| 45 |
|
| 46 |
+
1. Create a template with container image `plx1029/comfyui-qwen:v5`.
|
| 47 |
2. Expose HTTP port **7865** (plus 8888/22 as usual).
|
| 48 |
+
3. Set `HUGGING_FACE_ACCESS_TOKEN` in the template env (used for the boot-time
|
| 49 |
+
workflow/script refresh and by `download_missing_models.sh`).
|
| 50 |
+
4. (Optional) attach your network volume at `/workspace`.
|
| 51 |
+
5. In a terminal: `download_missing_models.sh` to fetch models for your
|
| 52 |
+
workflows, then `comfy` to start ComfyUI (or set `COMFY_AUTOSTART=true`).
|
| 53 |
|
| 54 |
+
`COMFY_PORT` overrides the port. `COMFY_AUTOSTART=true` enables auto-start
|
| 55 |
+
(otherwise run `comfy` manually). `WORKSPACE_REFRESH=false` skips the boot
|
| 56 |
+
refresh.
|
| 57 |
|
| 58 |
## How the image was built
|
| 59 |
|
|
|
|
| 63 |
**v3 with `crane append`** — a single layer holding `/workspace` (ComfyUI +
|
| 64 |
workflows + downloader), the seed tarball, the new startup scripts, and a
|
| 65 |
whiteout of the old `/ComfyUI`, appended on top of v2 (the ~11 GB base is never
|
| 66 |
+
re-uploaded); **v4 with `crane append` on top of v3** (no-auto-start
|
| 67 |
+
`start-comfy.sh`, boot refresh of the downloader, updated seed tarball);
|
| 68 |
+
**v5 with `crane append` on top of v4** — a small layer holding
|
| 69 |
+
`refresh-workspace.sh`, the updated `start-comfy.sh`, `/root/.bash_aliases`,
|
| 70 |
+
and current `workflows/` + `download_missing_models.sh` copies.
|
| 71 |
+
|
| 72 |
+
Note: `/opt/workspace-seed.tar.gz` inside v5 still holds the v4-era workflows
|
| 73 |
+
and script — that's fine, the boot refresh replaces them on the next start.
|
| 74 |
|
| 75 |
`Dockerfile` in this directory is the reproducible equivalent for rebuilding on
|
| 76 |
any machine with real Docker (build from the repo root — the context needs
|
| 77 |
`download_missing_models.sh` and `workflows/`):
|
| 78 |
|
| 79 |
```bash
|
| 80 |
+
docker build -t plx1029/comfyui-qwen:v5 -f docker/Dockerfile .
|
| 81 |
+
docker push plx1029/comfyui-qwen:v5
|
| 82 |
```
|
docker/bash_aliases
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Baked into plx1029/comfyui-qwen (sourced by /root/.bashrc): `claude` always
|
| 2 |
+
# runs with sandbox flag + permissions skipped — this is a throwaway pod.
|
| 3 |
+
alias claude='IS_SANDBOX=1 claude --dangerously-skip-permissions'
|
docker/refresh-workspace.sh
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Pull the freshest workflows/, download_missing_models.sh, and README.md from
|
| 3 |
+
# the HF repo (aleph65/ComfyUI) into /workspace on every boot, so pods never
|
| 4 |
+
# run against the stale copies baked into the image or left on a network
|
| 5 |
+
# volume. Best-effort: on any failure (offline, bad token, read-only
|
| 6 |
+
# /workspace) the existing copies stay in place and startup never blocks.
|
| 7 |
+
# Set WORKSPACE_REFRESH=false in the pod env to skip.
|
| 8 |
+
|
| 9 |
+
REPO_ID="aleph65/ComfyUI"
|
| 10 |
+
TAG="[refresh-workspace]"
|
| 11 |
+
TOKEN="${HUGGING_FACE_ACCESS_TOKEN:-${HF_TOKEN:-}}"
|
| 12 |
+
|
| 13 |
+
if [[ "${WORKSPACE_REFRESH:-true}" == "false" ]]; then
|
| 14 |
+
echo "$TAG disabled via WORKSPACE_REFRESH=false — skipping."
|
| 15 |
+
exit 0
|
| 16 |
+
fi
|
| 17 |
+
if [[ ! -d /workspace || ! -w /workspace ]]; then
|
| 18 |
+
echo "$TAG /workspace missing or not writable — skipping." >&2
|
| 19 |
+
exit 0
|
| 20 |
+
fi
|
| 21 |
+
|
| 22 |
+
set -u
|
| 23 |
+
|
| 24 |
+
# 1) single files: atomic swap, keep the old copy on any failure
|
| 25 |
+
update_workspace_file() {
|
| 26 |
+
local name="$1" check="$2"
|
| 27 |
+
local url="https://huggingface.co/$REPO_ID/resolve/main/$name"
|
| 28 |
+
local dest="/workspace/$name"
|
| 29 |
+
local tmp auth=()
|
| 30 |
+
tmp=$(mktemp) || return 0
|
| 31 |
+
[[ -n "$TOKEN" ]] && auth=(-H "Authorization: Bearer $TOKEN")
|
| 32 |
+
if curl -fsSL --connect-timeout 10 --max-time 60 "${auth[@]}" "$url" -o "$tmp" \
|
| 33 |
+
&& head -c 2 "$tmp" | grep -q "$check"; then
|
| 34 |
+
if ! cmp -s "$tmp" "$dest" 2>/dev/null; then
|
| 35 |
+
[[ "$name" == *.sh ]] && chmod 755 "$tmp" || chmod 644 "$tmp"
|
| 36 |
+
mv "$tmp" "$dest"
|
| 37 |
+
echo "$TAG updated $name from hf.co/$REPO_ID."
|
| 38 |
+
fi
|
| 39 |
+
else
|
| 40 |
+
echo "$TAG could not fetch latest $name — keeping existing copy." >&2
|
| 41 |
+
fi
|
| 42 |
+
rm -f "$tmp"
|
| 43 |
+
}
|
| 44 |
+
update_workspace_file download_missing_models.sh '#!' || true
|
| 45 |
+
update_workspace_file README.md '.' || true
|
| 46 |
+
|
| 47 |
+
# 2) mirror workflows/ from the repo (temp snapshot + rsync --delete, so
|
| 48 |
+
# renamed/removed workflows disappear too; local-only edits do NOT survive —
|
| 49 |
+
# the repo is the source of truth)
|
| 50 |
+
TMP_DIR=$(mktemp -d)
|
| 51 |
+
if timeout 240 python3 - "$REPO_ID" "$TMP_DIR" "$TOKEN" <<'PY'
|
| 52 |
+
import sys
|
| 53 |
+
repo_id, tmp, token = sys.argv[1], sys.argv[2], sys.argv[3]
|
| 54 |
+
from huggingface_hub import snapshot_download
|
| 55 |
+
snapshot_download(repo_id=repo_id, allow_patterns=["workflows/*"],
|
| 56 |
+
local_dir=tmp, token=token or None)
|
| 57 |
+
PY
|
| 58 |
+
then
|
| 59 |
+
if [[ -d "$TMP_DIR/workflows" ]]; then
|
| 60 |
+
rsync -a --delete --exclude='.cache' "$TMP_DIR/workflows/" /workspace/workflows/
|
| 61 |
+
echo "$TAG workflows/ synced from hf.co/$REPO_ID ($(find /workspace/workflows -name '*.json' | wc -l) json files)."
|
| 62 |
+
else
|
| 63 |
+
echo "$TAG snapshot returned no workflows/ — keeping existing copies." >&2
|
| 64 |
+
fi
|
| 65 |
+
else
|
| 66 |
+
echo "$TAG workflows sync failed — keeping existing copies." >&2
|
| 67 |
+
fi
|
| 68 |
+
rm -rf "$TMP_DIR"
|
docker/start-comfy.sh
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
-
# Image CMD: make sure /workspace is fully populated,
|
| 3 |
-
#
|
| 4 |
-
# /start.sh (SSH, Jupyter, nginx).
|
| 5 |
-
#
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
/usr/local/bin/seed-workspace.sh || true
|
|
|
|
| 8 |
|
| 9 |
-
if [[ "${COMFY_AUTOSTART:-
|
| 10 |
LOG=/workspace/comfyui.log
|
| 11 |
[[ -d /workspace && -w /workspace ]] || LOG=/var/log/comfyui.log
|
| 12 |
(
|
|
@@ -19,7 +23,7 @@ if [[ "${COMFY_AUTOSTART:-true}" != "false" ]]; then
|
|
| 19 |
echo "ComfyUI starting in background (log: $LOG, port ${COMFY_PORT:-7865})"
|
| 20 |
echo "Run 'download_missing_models.sh' to fetch models for your workflows."
|
| 21 |
else
|
| 22 |
-
echo "ComfyUI not auto-started
|
| 23 |
fi
|
| 24 |
|
| 25 |
exec /start.sh
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
+
# Image CMD: make sure /workspace is fully populated, refresh workflows/,
|
| 3 |
+
# download_missing_models.sh, and README.md from the HF repo, then hand off
|
| 4 |
+
# to the stock RunPod /start.sh (SSH, Jupyter, nginx).
|
| 5 |
+
# v4: ComfyUI does NOT auto-start (start it manually with 'comfy' or
|
| 6 |
+
# python main.py). Set COMFY_AUTOSTART=true to re-enable the old behavior.
|
| 7 |
+
# v5: the boot refresh moved to refresh-workspace.sh and now also mirrors
|
| 8 |
+
# workflows/ from hf.co/aleph65/ComfyUI (WORKSPACE_REFRESH=false to skip).
|
| 9 |
|
| 10 |
/usr/local/bin/seed-workspace.sh || true
|
| 11 |
+
/usr/local/bin/refresh-workspace.sh || true
|
| 12 |
|
| 13 |
+
if [[ "${COMFY_AUTOSTART:-false}" == "true" ]]; then
|
| 14 |
LOG=/workspace/comfyui.log
|
| 15 |
[[ -d /workspace && -w /workspace ]] || LOG=/var/log/comfyui.log
|
| 16 |
(
|
|
|
|
| 23 |
echo "ComfyUI starting in background (log: $LOG, port ${COMFY_PORT:-7865})"
|
| 24 |
echo "Run 'download_missing_models.sh' to fetch models for your workflows."
|
| 25 |
else
|
| 26 |
+
echo "ComfyUI not auto-started. Run 'comfy' (or cd /workspace/ComfyUI && python main.py --listen 0.0.0.0 --port ${COMFY_PORT:-7865} --enable-manager) to start it."
|
| 27 |
fi
|
| 28 |
|
| 29 |
exec /start.sh
|