File size: 1,064 Bytes
1b4b5a0
71303dd
 
 
a6f119f
 
 
 
 
 
 
 
 
 
7420d2a
 
 
 
 
 
 
1b4b5a0
 
 
71303dd
 
1b4b5a0
 
 
71303dd
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.10

WORKDIR /app

# Create cache directories with proper permissions
RUN mkdir -p /app/.cache /app/.huggingface && \
    chmod 777 /app/.cache /app/.huggingface

# Set environment variables for cache directories
ENV HF_HOME=/app/.huggingface
ENV TRANSFORMERS_CACHE=/app/.huggingface
ENV HF_DATASETS_CACHE=/app/.huggingface
ENV TORCH_HOME=/app/.cache

# Install system dependencies for building Python packages
RUN apt-get update && apt-get install -y \
    gcc \
    g++ \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Upgrade pip and install wheel to use pre-compiled packages when possible
RUN pip install --upgrade pip wheel

# Copy requirements and install dependencies
COPY requirements.txt .

# Install packages with timeout and prefer binary wheels
RUN pip install --no-cache-dir --timeout 300 --prefer-binary -r requirements.txt

# Download spaCy model
RUN python -m spacy download en_core_web_sm

# Copy application files
COPY . .

# Expose port for HuggingFace Spaces
EXPOSE 7860

# Run the Flask app
CMD ["python", "app.py"]