File size: 3,794 Bytes
c959ce5
bd41f1c
 
 
 
835f43b
 
 
 
 
bd41f1c
 
 
 
 
835f43b
bd41f1c
 
 
 
 
 
 
 
cb68dd7
 
 
 
 
 
 
 
 
 
 
bd41f1c
 
 
 
 
 
835f43b
bd41f1c
 
 
db49311
bd41f1c
 
 
 
 
 
 
 
 
 
835f43b
 
2577eef
e6ed025
 
699a2e1
 
7c7dd01
699a2e1
7cca4f9
 
 
 
 
 
 
2577eef
699a2e1
7b05cbe
7cca4f9
7b05cbe
2577eef
835f43b
 
f366d80
7cca4f9
 
835f43b
 
849b0ad
 
 
2577eef
 
 
699a2e1
835f43b
699a2e1
 
7cca4f9
835f43b
849b0ad
2577eef
a84d73f
6ac1e56
835f43b
19231d8
 
 
 
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive \
    TZ=America/Los_Angeles

ARG HF_TOKEN
ENV HF_TOKEN=${HF_TOKEN}

ARG USE_PERSISTENT_DATA=false
ENV USE_PERSISTENT_DATA=${USE_PERSISTENT_DATA}

RUN apt-get update && apt-get install -y \
    git \
    make build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git git-lfs \
    ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx \
    && rm -rf /var/lib/apt/lists/* \
    && git lfs install

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

# Persistent directory structure (as root)
RUN mkdir -p /data/ComfyUI/models/checkpoints \
             /data/ComfyUI/models/loras \
             /data/ComfyUI/models/vae \
             /data/ComfyUI/models/controlnet \
             /data/ComfyUI/models/upscale_models \
             /data/ComfyUI/models/gligen \
             /data/ComfyUI/custom_nodes \
             /data/ComfyUI/output && \
    chown -R 1000:1000 /data

# User
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

# Pyenv + Python
RUN curl https://pyenv.run | bash
ENV PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH

ARG PYTHON_VERSION=3.10.12
RUN pyenv install $PYTHON_VERSION && \
    pyenv global $PYTHON_VERSION && \
    pyenv rehash && \
    pip install --no-cache-dir --upgrade pip setuptools wheel && \
    pip install --no-cache-dir \
    datasets \
    huggingface-hub "protobuf<4" "click<8.1"

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

WORKDIR /data/ComfyUI

# Clean clone latest ComfyUI
RUN rm -rf * && \
    git clone https://github.com/comfyanonymous/ComfyUI . && \
    git pull && \
    pip install xformers --no-cache-dir -r requirements.txt --extra-index-url https://download.pytorch.org/whl/cu121

# Link private bucket folders
RUN echo "Linking private bucket folders..." && \
    ln -sfn /dataprivate/custom_nodes /data/ComfyUI/custom_nodes 2>/dev/null || true && \
    ln -sfn /dataprivate/workflows /data/ComfyUI/workflows 2>/dev/null || true && \
    ln -sfn /dataprivate/input /data/ComfyUI/input 2>/dev/null || true && \
    ln -sfn /dataprivate/output /data/ComfyUI/output 2>/dev/null || true && \
    echo "Private bucket folders linked."

# Copy additional custom nodes from public bucket (fallback)
RUN echo "Copying additional custom nodes from public bucket..." && \
    cp -r /datapublic/comfy/custom_nodes/ComfyUI-Manager-main /data/ComfyUI/custom_nodes/ComfyUI-Manager 2>/dev/null || true && \
    echo "Additional nodes copied."

# Run install scripts
RUN cd /data/ComfyUI/custom_nodes/comfyui_controlnet_aux && pip install -r requirements.txt || true
RUN cd /data/ComfyUI/custom_nodes/stability-ComfyUI-nodes && pip install -r requirements.txt || true

# Startup script
USER root
COPY <<'EOF' /start.sh
#!/bin/bash
echo "=== Container started as $(whoami) ==="
echo "Current dir: $(pwd)"

echo "=== Bucket contents ==="
ls -la /datapublic/comfy 2>&1 | cat || echo "No /datapublic/comfy"

echo "=== Copying models from public bucket ==="
if [ -d "/datapublic/comfy" ]; then
  cp -nv /datapublic/comfy/stabilityai/sd-vae-ft-mse-original/vae-ft-mse-840000-ema-pruned.safetensors /data/ComfyUI/models/vae/ 2>&1 || true
  cp -nv /datapublic/comfy/LA0077/v1-5-pruned-emaonly-fp16.safetensors/v1-5-pruned-emaonly-fp16.safetensors /data/ComfyUI/models/checkpoints/ 2>&1 || true
  echo "Models copied."
fi

echo "=== Starting ComfyUI (verbose) ==="
cd /data/ComfyUI
exec python main.py --listen 0.0.0.0 --port 7860 --output-directory "/dataprivate/output" --front-end-version latest --verbose 2>&1
EOF
RUN chmod +x /start.sh
USER user

CMD ["/start.sh"]