Nodiw52992 commited on
Commit
a30b396
·
verified ·
1 Parent(s): a070074

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -13
Dockerfile CHANGED
@@ -2,26 +2,45 @@
2
  FROM ubuntu:24.04
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
- RUN apt-get update && apt-get install -y python3-venv python3-pip git wget && \
6
- rm -rf /var/lib/apt/lists/*
 
7
 
8
  WORKDIR /workspace
9
  RUN git clone https://github.com/comfyanonymous/ComfyUI.git
10
  WORKDIR /workspace/ComfyUI
11
 
12
- RUN python3 -m venv .venv && . .venv/bin/activate && \
13
- pip install --upgrade pip && pip install xformers!=0.0.18 && \
14
- pip install -r requirements.txt
 
 
 
15
 
 
16
  RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
17
- mkdir -p models/unet models/vae && \
18
- hf=$(cat /run/secrets/HF_TOKEN) && \
19
- wget --header="Authorization: Bearer $hf" \
20
- https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/flux1-schnell.safetensors \
21
- -O models/unet/flux1-schnell.safetensors && \
22
- wget --header="Authorization: Bearer $hf" \
23
- https://huggingface.co/black-forest-labs/FLUX.1-schnell/resolve/main/ae.safetensors \
24
- -O models/vae/ae.safetensors
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  EXPOSE 7860
27
 
 
2
  FROM ubuntu:24.04
3
  ENV DEBIAN_FRONTEND=noninteractive
4
 
5
+ RUN apt-get update && apt-get install -y \
6
+ python3 python3-venv python3-pip git wget \
7
+ && rm -rf /var/lib/apt/lists/*
8
 
9
  WORKDIR /workspace
10
  RUN git clone https://github.com/comfyanonymous/ComfyUI.git
11
  WORKDIR /workspace/ComfyUI
12
 
13
+ # Install dependencies including huggingface_hub
14
+ RUN python3 -m venv .venv \
15
+ && . .venv/bin/activate \
16
+ && pip install --upgrade pip \
17
+ && pip install huggingface_hub xformers!=0.0.18 \
18
+ && pip install -r requirements.txt
19
 
20
+ # Download model files securely using hf_hub_download
21
  RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
22
+ . .venv/bin/activate && \
23
+ python3 - << 'EOF'
24
+ import os
25
+ from huggingface_hub import hf_hub_download
26
+ hf = open('/run/secrets/HF_TOKEN').read().strip()
27
+ # UNET
28
+ hf_hub_download(
29
+ repo_id="black-forest-labs/FLUX.1-schnell",
30
+ filename="flux1-schnell.safetensors",
31
+ token=hf,
32
+ local_dir="models/unet",
33
+ force_download=True
34
+ )
35
+ # VAE
36
+ hf_hub_download(
37
+ repo_id="black-forest-labs/FLUX.1-schnell",
38
+ filename="ae.safetensors",
39
+ token=hf,
40
+ local_dir="models/vae",
41
+ force_download=True
42
+ )
43
+ EOF
44
 
45
  EXPOSE 7860
46