File size: 1,353 Bytes
a9ff387
14dbbd8
 
a9ff387
 
 
 
 
 
 
 
14dbbd8
 
a9ff387
 
14dbbd8
 
a9ff387
14dbbd8
 
a9ff387
 
 
 
 
 
 
 
14dbbd8
a9ff387
 
14dbbd8
a9ff387
14dbbd8
 
a9ff387
 
 
14dbbd8
a9ff387
64c2d87
 
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
# Dockerfile - Streamlit app for huggingface model
FROM python:3.13.5-slim

ENV PYTHONUNBUFFERED=1 \
    HF_HOME=/tmp/huggingface \
    TRANSFORMERS_CACHE=/tmp/huggingface/transformers \
    HF_DATASETS_CACHE=/tmp/huggingface/datasets \
    HUGGINGFACE_HUB_CACHE=/tmp/huggingface/hub \
    XDG_CACHE_HOME=/tmp/huggingface \
    HOME=/tmp

WORKDIR /app

# Install system deps
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

# create cache dirs early (prevents permission errors in Spaces)
RUN mkdir -p /tmp/huggingface/transformers /tmp/huggingface/datasets /tmp/huggingface/hub \
    && chmod -R 777 /tmp/huggingface

# copy requirements and install
COPY requirements.txt /app/requirements.txt
RUN python -m pip install --upgrade pip
RUN pip install -r /app/requirements.txt

# copy app
COPY . /app

# Expose Streamlit port (Spaces and local Streamlit default)
EXPOSE 8501

# Healthcheck (simple)
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
  CMD curl --fail http://localhost:8501/_stcore/health || exit 1

# Start streamlit
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.headless=true", "--server.enableCORS=false", "--server.enableXsrfProtection=false"]