1
1
# Stage 1: Base image with common dependencies
2
- FROM nvidia/cuda:11.8.0-cudnn8 -runtime-ubuntu22.04 as base
2
+ FROM nvidia/cuda:12.6.3-cudnn -runtime-ubuntu22.04 AS base
3
3
4
4
# Prevents prompts from packages asking for user input during installation
5
5
ENV DEBIAN_FRONTEND=noninteractive
@@ -12,36 +12,40 @@ ENV CMAKE_BUILD_PARALLEL_LEVEL=8
12
12
13
13
# Install Python, git and other necessary tools
14
14
RUN apt-get update && apt-get install -y \
15
- python3.10 \
15
+ python3.11 \
16
16
python3-pip \
17
17
git \
18
18
wget \
19
19
libgl1 \
20
- && ln -sf /usr/bin/python3.10 /usr/bin/python \
20
+ && ln -sf /usr/bin/python3.11 /usr/bin/python \
21
21
&& ln -sf /usr/bin/pip3 /usr/bin/pip
22
22
23
23
# Clean up to reduce image size
24
24
RUN apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
25
25
26
+ # Install uv
27
+ RUN pip install uv
28
+
26
29
# Install comfy-cli
27
- RUN pip install comfy-cli
30
+ RUN uv pip install comfy-cli --system
28
31
29
32
# Install ComfyUI
30
- RUN /usr/bin/yes | comfy --workspace /comfyui install --cuda-version 11.8 --nvidia --version 0.3.26
33
+ RUN /usr/bin/yes | comfy --workspace /comfyui install --version 0.3.29 -- cuda-version 12.6 --nvidia --skip-manager
31
34
32
35
# Change working directory to ComfyUI
33
36
WORKDIR /comfyui
34
37
35
- # Install runpod
36
- RUN pip install runpod requests
37
-
38
38
# Support for the network volume
39
39
ADD src/extra_model_paths.yaml ./
40
40
41
41
# Go back to the root
42
42
WORKDIR /
43
43
44
- # Add scripts
44
+ # install dependencies
45
+ RUN uv pip install runpod requests --system
46
+
47
+
48
+ # Add files
45
49
ADD src/start.sh src/restore_snapshot.sh src/rp_handler.py test_input.json ./
46
50
RUN chmod +x /start.sh /restore_snapshot.sh
47
51
@@ -55,18 +59,19 @@ RUN /restore_snapshot.sh
55
59
CMD ["/start.sh" ]
56
60
57
61
# Stage 2: Download models
58
- FROM base as downloader
62
+ FROM base AS downloader
59
63
60
64
ARG HUGGINGFACE_ACCESS_TOKEN
61
- ARG MODEL_TYPE
65
+ # Set default model type if none is provided
66
+ ARG MODEL_TYPE=flux1-dev-fp8
62
67
63
68
# Change working directory to ComfyUI
64
69
WORKDIR /comfyui
65
70
66
- # Create necessary directories
67
- RUN mkdir -p models/checkpoints models/vae
71
+ # Create necessary directories upfront
72
+ RUN mkdir -p models/checkpoints models/vae models/unet models/clip
68
73
69
- # Download checkpoints/vae/LoRA to include in image based on model type
74
+ # Download checkpoints/vae/unet/clip models to include in image based on model type
70
75
RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \
71
76
wget -O models/checkpoints/sd_xl_base_1.0.safetensors https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors && \
72
77
wget -O models/vae/sdxl_vae.safetensors https://huggingface.co/stabilityai/sdxl-vae/resolve/main/sdxl_vae.safetensors && \
@@ -79,14 +84,18 @@ RUN if [ "$MODEL_TYPE" = "sdxl" ]; then \
79
84
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
80
85
wget -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors; \
81
86
elif [ "$MODEL_TYPE" = "flux1-dev" ]; then \
87
+ # Full precision FLUX.1 dev
82
88
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/unet/flux1-dev.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/flux1-dev.safetensors && \
83
89
wget -O models/clip/clip_l.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/clip_l.safetensors && \
84
90
wget -O models/clip/t5xxl_fp8_e4m3fn.safetensors https://huggingface.co/comfyanonymous/flux_text_encoders/resolve/main/t5xxl_fp8_e4m3fn.safetensors && \
85
91
wget --header="Authorization: Bearer ${HUGGINGFACE_ACCESS_TOKEN}" -O models/vae/ae.safetensors https://huggingface.co/black-forest-labs/FLUX.1-dev/resolve/main/ae.safetensors; \
92
+ elif [ "$MODEL_TYPE" = "flux1-dev-fp8" ]; then \
93
+ # Default model if none specified during build
94
+ wget -O models/checkpoints/flux1-dev-fp8.safetensors https://huggingface.co/Comfy-Org/flux1-dev/resolve/main/flux1-dev-fp8.safetensors; \
86
95
fi
87
96
88
97
# Stage 3: Final image
89
- FROM base as final
98
+ FROM base AS final
90
99
91
100
# Copy models from stage 2 to the final image
92
101
COPY --from=downloader /comfyui/models /comfyui/models
0 commit comments