Spaces:
Running
Running
| # Base image with Python and common dependencies | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Set environment variables | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| TRANSFORMERS_CACHE=/app/cache \ | |
| HF_HOME=/app/cache | |
| # COPY requirements file and install Python dependencies | |
| COPY requirements.txt requirements.txt | |
| COPY extract_img_pdf.py extract_img_pdf.py | |
| COPY live_streaming_flask.py live_streaming_flask.py | |
| COPY templates/ /app/templates | |
| COPY .env .env | |
| COPY test_streaming.py test_streaming.py | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| tesseract-ocr \ | |
| poppler-utils \ | |
| libgl1 \ | |
| ffmpeg \ | |
| libopencv-dev \ | |
| && apt-get clean && rm -rf /var/lib/apt/lists/* | |
| RUN pip install -r requirements.txt | |
| # Fontconfig Warning Suppression (optional) | |
| ENV FONTCONFIG_PATH=/etc/fonts | |
| ENV FONTCONFIG_FILE=/etc/fonts/fonts.conf | |
| # Set writable path for nltk data | |
| ENV NLTK_DATA=/app/nltk_data | |
| RUN mkdir -p /app/nltk_data | |
| # Pre-download required NLTK models | |
| RUN python -m nltk.downloader -d /app/nltk_data \ | |
| punkt averaged_perceptron_tagger averaged_perceptron_tagger_eng | |
| RUN mkdir -p /app/cache /app/data && chmod -R 777 /app/cache /app/data | |
| RUN mkdir -p /app/OUTPUTS | |
| RUN chmod -R 777 /app | |
| # Expose the required port for HF Spaces | |
| EXPOSE 7860 | |
| # Set the command to run your Flask app | |
| # CMD ["python", "extract_img_pdf.py"] | |
| # CMD ["python", "live_streaming_flask.py"] | |
| CMD ["python", "test_streaming.py"] | |