File size: 2,383 Bytes
372d5c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
# ── OphthalmoCapture – Hugging Face Spaces (Docker + Streamlit) ──────────────
FROM python:3.10-slim

# ── System dependencies ──────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
        ffmpeg \
        build-essential \
        git \
    && rm -rf /var/lib/apt/lists/*

# ── Non-root user (HF Spaces requirement) ───────────────────────────────────
RUN useradd -m -u 1000 user
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH

WORKDIR $HOME/app

# ── Python dependencies ──────────────────────────────────────────────────────
COPY --chown=user requirements.txt .
USER user
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# ── Pre-download Whisper model (base.en) to bake into image ─────────────────
# This avoids a ~150 MB download on every cold start.
# Change to "small" / "medium" if you upgrade hardware.
RUN python -c "import whisper; whisper.load_model('base.en')"

# ── Copy application code ───────────────────────────────────────────────────
COPY --chown=user . .

# ── Streamlit configuration ─────────────────────────────────────────────────
# HF Spaces expects port 7860
EXPOSE 7860

HEALTHCHECK CMD curl --fail http://localhost:7860/_stcore/health || exit 1

# ── Launch ───────────────────────────────────────────────────────────────────
ENTRYPOINT ["streamlit", "run", "interface/main.py", \
            "--server.port=7860", \
            "--server.address=0.0.0.0", \
            "--server.enableCORS=false", \
            "--server.enableXsrfProtection=false", \
            "--browser.gatherUsageStats=false"]