ARG PYTORCH_IMAGE=pytorch/pytorch:2.11.0-cuda12.8-cudnn9-runtime
FROM ${PYTORCH_IMAGE}

ARG COMFYUI_COMMIT
RUN test -n "$COMFYUI_COMMIT" \
    && apt-get update \
    && apt-get install -y --no-install-recommends git ca-certificates \
    && git clone --filter=blob:none https://github.com/Comfy-Org/ComfyUI.git /opt/ComfyUI \
    && git -C /opt/ComfyUI checkout "$COMFYUI_COMMIT" \
    && python -m pip install --break-system-packages --no-cache-dir \
       -r /opt/ComfyUI/requirements.txt \
    && apt-get purge -y --auto-remove git \
    && rm -rf /var/lib/apt/lists/* /root/.cache

WORKDIR /opt/ComfyUI
COPY qwen_image_worker.py /opt/qwen-image-worker.py
EXPOSE 8086
CMD ["python", "/opt/qwen-image-worker.py"]
