File size: 2,504 Bytes
a756e18
 
 
 
 
 
 
 
 
125ea29
a756e18
 
 
 
5e89217
125ea29
61aa57c
a756e18
 
 
 
 
 
 
 
125ea29
 
 
 
 
 
 
 
255b292
 
 
 
 
 
a756e18
61aa57c
 
 
 
a756e18
30e9658
 
 
 
 
a756e18
 
 
 
 
 
 
 
 
255b292
 
a756e18
 
61aa57c
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
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04

ENV DEBIAN_FRONTEND=noninteractive \
    TZ=America/Los_Angeles

RUN apt-get update && apt-get install -y \
    git \
    python3 \
    python3-pip \
    python3-venv \
    ffmpeg \
    libsm6 \
    libxext6 \
    libgl1-mesa-glx \
    wget \
    curl \
    && rm -rf /var/lib/apt/lists/*

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

WORKDIR $HOME/app

# Set up a virtual environment
RUN python3 -m venv venv
ENV PATH="$HOME/app/venv/bin:$PATH"

COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Clone ComfyUI into a subdirectory
RUN git clone https://github.com/comfyanonymous/ComfyUI.git comfyui
WORKDIR $HOME/app/comfyui
RUN pip install --no-cache-dir -r requirements.txt

WORKDIR $HOME/app

# Download specific models
ARG HF_TOKEN
ARG HUGGINGFACE_TOKEN

RUN mkdir -p ./models/unet ./models/vae ./models/clip && \
    curl -L -H "Authorization: Bearer ${HUGGINGFACE_TOKEN}" -o ./models/unet/flux1-dev.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors && \
    curl -L -H "Authorization: Bearer ${HUGGINGFACE_TOKEN}" -o ./models/vae/diffusion_pytorch_model.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/vae/diffusion_pytorch_model.safetensors && \
    curl -L -H "Authorization: Bearer ${HUGGINGFACE_TOKEN}" -o ./models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
    curl -L -H "Authorization: Bearer ${HUGGINGFACE_TOKEN}" -o ./models/clip/t5xxl_fp16.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp16.safetensors && \
    curl -L -H "Authorization: Bearer ${HUGGINGFACE_TOKEN}" -o ./models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors

# Copy wsj-server.py
COPY --chown=user wsj-server.py .

# Expose ports for ComfyUI and wsj-server
EXPOSE 8188 7860

# Create entrypoint script
RUN echo '#!/bin/bash\n\

    cd $HOME/app/comfyui && python main.py --listen 0.0.0.0 --port 8188 --use-split-cross-attention &\n\

    cd $HOME/app && python wsj-server.py &\n\

    wait -n' > entrypoint.sh && chmod +x entrypoint.sh

CMD ["./entrypoint.sh"]