File size: 1,246 Bytes
485459a
 
 
 
 
 
 
1413ebb
485459a
 
06b7929
485459a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c820a30
 
 
5394bd3
 
1413ebb
 
485459a
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
FROM python:3.11-slim AS runtime
ENV DEBIAN_FRONTEND=noninteractive \
    PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PORT=7860 \
    HOST=0.0.0.0 \
    GRADIO_SERVER_NAME=0.0.0.0 \
    P5_FLUX_MODEL_DIR=models/FLUX.2-klein-base-4B

RUN apt-get update \
    && apt-get install -y --no-install-recommends git ca-certificates libcurl4 libgomp1 libstdc++6 \
    && rm -rf /var/lib/apt/lists/*

RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

COPY --chown=user requirements.txt ./requirements.txt
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel \
    && python -m pip install --no-cache-dir -r requirements.txt

COPY --chown=user . /app

ARG HF_TOKEN
ENV HF_TOKEN=${HF_TOKEN}
RUN pip install huggingface_hub hf_transfer
USER root
RUN mkdir -p /data && chown -R user:user /data
USER user
RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=false \
    if [ -f /run/secrets/HF_TOKEN ]; then export HF_TOKEN=$(cat /run/secrets/HF_TOKEN); fi && \
    python scripts/download_model.py black-forest-labs/FLUX.2-klein-base-4B models/FLUX.2-klein-base-4B && \
    python scripts/download_model.py openbmb/MiniCPM5-1B models/MiniCPM5-1B

EXPOSE 7860
CMD ["python", "app.py"]