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"]