File size: 909 Bytes
5bde3f1
 
 
 
 
 
 
 
 
 
 
35ead53
 
 
 
 
5bde3f1
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    gcc \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements first for better caching
COPY requirements.txt .

# Install dependencies with pip upgrade to ensure latest resolver
# Use --no-deps for httpx to let OpenAI manage its own dependencies, then install httpx separately
RUN pip install --upgrade pip setuptools wheel && \
    pip install --no-cache-dir -r requirements.txt

# Copy application code
COPY . .

# Expose port (HuggingFace uses port 7860)
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
  CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1

# Run Flask app with Gunicorn
CMD python -m gunicorn --bind 0.0.0.0:7860 --workers 2 --timeout 120 --access-logfile - --error-logfile - app:app