File size: 1,126 Bytes
29d0879
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.9-slim

WORKDIR /code

# Install system dependencies including tesseract for OCR
RUN apt-get update && apt-get install -y \
    tesseract-ocr \
    tesseract-ocr-eng \
    poppler-utils \
    git \
    && rm -rf /var/lib/apt/lists/*

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

# Set environment variables for cache directories
ENV TRANSFORMERS_CACHE=/code/.cache/huggingface
ENV HF_HOME=/code/.cache/huggingface
ENV TORCH_HOME=/code/.cache/torch
ENV HF_HUB_CACHE=/code/.cache/huggingface
ENV SENTENCE_TRANSFORMERS_HOME=/code/.cache/sentence_transformers

# Copy requirements and install Python dependencies
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

# Copy application files
COPY . /code

# Create necessary directories
RUN mkdir -p /code/static /code/templates

# Expose port
EXPOSE 7860

# Set environment variable for Hugging Face Spaces
ENV PYTHONPATH=/code

# Command to run the application
CMD ["python", "app.py"]