# Reproducible Dockerfile equivalent of build.sh (which assembles the same # image daemonlessly with crane, since RunPod pods have no Docker daemon). # # Build from the HF-repo root (context needs serverless/ and apply_patches.sh), # passing your HF token as a BuildKit secret so it is never baked into a layer: # # DOCKER_BUILDKIT=1 docker build \ # -f serverless/Dockerfile \ # --secret id=hf_token,env=HF_TOKEN \ # --build-arg ENDPOINT=qwen-edit-turbo \ # -t plx1029/comfyui-serverless:qwen-edit-turbo-v1 . # # Layer order mirrors build.sh: custom nodes + models first (heavy, rarely # change), serverless code last (tiny, changes often) — so code iterations # never re-push model layers. FROM plx1029/comfyui-qwen:v6 ARG ENDPOINT=qwen-edit-turbo ARG CUSTOM_SCRIPTS_COMMIT=main ARG QWENEDITUTILS_COMMIT=main # ---- custom nodes (rgthree already ships in the base) ---- RUN git clone https://github.com/pythongosssss/ComfyUI-Custom-Scripts.git \ /workspace/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts && \ git -C /workspace/ComfyUI/custom_nodes/ComfyUI-Custom-Scripts checkout ${CUSTOM_SCRIPTS_COMMIT} && \ git clone https://github.com/lrzjason/Comfyui-QwenEditUtils.git \ /workspace/ComfyUI/custom_nodes/Comfyui-QwenEditUtils && \ git -C /workspace/ComfyUI/custom_nodes/Comfyui-QwenEditUtils checkout ${QWENEDITUTILS_COMMIT} # ---- models: one RUN (= one layer) per file, list must match endpoint.json ---- COPY serverless/endpoints/${ENDPOINT}/endpoint.json /tmp/endpoint.json RUN pip install -q -U huggingface_hub # hf download reads the token from the mounted secret; one layer per model RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/diffusion_models/qwen_image_edit_2511_bf16.safetensors --local-dir /workspace/ComfyUI RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/text_encoders/qwen_2.5_vl_7b.safetensors --local-dir /workspace/ComfyUI RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/vae/qwen_image_vae.safetensors --local-dir /workspace/ComfyUI RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/loras/Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors --local-dir /workspace/ComfyUI RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/loras/Qwen-Image-Edit-2511-Lightning-8steps-V1.0-bf16.safetensors --local-dir /workspace/ComfyUI RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/loras/Qwen_LoRA_Skin_Fix_v2.safetensors --local-dir /workspace/ComfyUI RUN --mount=type=secret,id=hf_token HF_TOKEN=$(cat /run/secrets/hf_token) \ hf download aleph65/ComfyUI models/loras/Qwen_LoRA_Amateur_Photo_v1.safetensors --local-dir /workspace/ComfyUI # ---- serverless code (top layer: cheap to rebuild) ---- COPY apply_patches.sh /workspace/apply_patches.sh RUN bash /workspace/apply_patches.sh COPY serverless/ /opt/serverless/src/ RUN rm -rf /opt/serverless/src/Dockerfile /opt/serverless/src/build.sh && \ find /opt/serverless/src/endpoints -mindepth 1 -maxdepth 1 ! -name "${ENDPOINT}" -exec rm -rf {} + && \ pip install -q --target /opt/serverless/lib runpod && \ chmod +x /opt/serverless/src/start.sh CMD ["/opt/serverless/src/start.sh"]