File size: 1,343 Bytes
32d4a86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Dockerfile for Hugging Face Spaces
# Based on: https://huggingface.co/docs/hub/spaces-sdks-docker

FROM python:3.10-slim

# Create user (HF Spaces requirement)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /app

# Install system dependencies
USER root
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

USER user

# Copy and install Python dependencies
COPY --chown=user requirements.txt requirements.txt
RUN pip install --no-cache-dir --user --upgrade -r requirements.txt

# Download NLTK data
RUN python -c "import nltk; nltk.download('punkt', quiet=True)"

# Copy application files
COPY --chown=user app/ /app/app/
COPY --chown=user training/ /app/training/
COPY --chown=user scripts/ /app/scripts/
COPY --chown=user templates/ /app/templates/
COPY --chown=user static/ /app/static/
COPY --chown=user app.py /app/

# Create necessary directories
RUN mkdir -p /app/models/optimized_models /app/uploads

# HF Spaces uses port 7860
EXPOSE 7860

# Set environment variables
ENV FLASK_ENV=production
ENV PORT=7860

# Run the application on port 7860 (HF Spaces requirement)
# Use app.py as entry point (HF Spaces looks for app.py)
CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "--threads", "2"]