File size: 1,335 Bytes
358c229
 
16a16ba
358c229
 
 
 
 
 
 
 
 
16a16ba
 
358c229
16a16ba
 
 
 
 
 
358c229
16a16ba
 
358c229
1a02cf0
 
 
16a16ba
358c229
 
16a16ba
1a02cf0
 
 
358c229
 
16a16ba
1a02cf0
 
 
 
358c229
1a02cf0
 
 
 
 
 
 
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
46
47
48
49
50
51
# Use a solid Python base (HF Spaces supports 3.10+)
FROM python:3.11-slim

# Environment variables for Python behavior
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    HF_HOME="/huggingface" \
    STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
    STREAMLIT_SERVER_PORT=7860

# Set workspace
WORKDIR /app

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

# Copy requirements first (to use Docker layer caching)
COPY requirements.txt ./

# Install Python dependencies
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir "httpx<0.28"

# Copy the rest of the application
COPY . .

# Create necessary directories
RUN mkdir -p /app/.streamlit /app/db

# Hugging Face Spaces uses port 7860
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
    CMD curl -f http://localhost:7860/_stcore/health || exit 1

# Launch Streamlit on Spaces' port (7860)
CMD ["streamlit", "run", "main.py", \
    "--server.port=7860", \
    "--server.address=0.0.0.0", \
    "--server.headless=true", \
    "--server.enableCORS=false", \
    "--server.enableXsrfProtection=false", \
    "--browser.gatherUsageStats=false"]