File size: 907 Bytes
0b04c62
 
c13f6e7
bed505c
c13f6e7
 
 
 
 
 
 
8a4da11
c13f6e7
 
20c961c
 
bed505c
c13f6e7
d47b49f
 
c13f6e7
 
 
bed505c
 
8a4da11
c13f6e7
bed505c
c13f6e7
d2832a2
c13f6e7
0b04c62
 
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
FROM python:3.10-slim

# 1. Install OS and Python dependencies
RUN apt-get update \
    && apt-get install -y build-essential curl git \
    && pip install --upgrade pip \
        onnxruntime-genai==0.8.3 \
        gradio \
        huggingface_hub>=0.33.3 \
        numpy \
    && rm -rf /var/lib/apt/lists/*

# 2. Download the ONNX model files at build time
RUN python - <<EOF
from huggingface_hub import snapshot_download
snapshot_download(
    repo_id="microsoft/Phi-4-mini-reasoning-onnx",
    subfolder="cpu_and_mobile/cpu-int4-rtn-block-32-acc-level-4",
    repo_type="model",
    local_dir="/phi4_model",
    repo_type="model",
    # restrict files to ONNX & config via allow_patterns
    allow_patterns=["*.onnx", "*.json", "*.txt"]
)
EOF

# 3. Set working directory and copy application code
WORKDIR /app
COPY app.py ./app.py

# 4. Open port and set entrypoint
EXPOSE 7860
CMD ["python", "app.py"]