FROM python:3.10-slim # Set non-interactive mode and default timezone to avoid hangs during package installation ENV DEBIAN_FRONTEND=noninteractive ENV TZ=UTC ENV PYTHONUNBUFFERED=1 ENV SYSTEM=spaces # Install system dependencies RUN apt-get update && apt-get install -y \ python3-pip \ git \ git-lfs \ texlive-latex-base \ texlive-fonts-recommended \ texlive-latex-extra \ libreoffice \ && git lfs install \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean # Create /data/uploads and set permissions as root RUN mkdir -p /data/uploads && chmod -R 777 /data/uploads && chmod -R 777 /tmp # Create non-root user (HF default) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONPATH=${HOME}/app WORKDIR ${HOME}/app # Copy application files COPY --chown=user . ${HOME}/app # Install Python dependencies RUN python3 -m pip install --user --no-cache-dir packaging==24.1 RUN python3 -m pip install --user --no-cache-dir -r requirements.txt # Expose Flask port (required for Hugging Face Spaces) EXPOSE 7860 # Run the Flask app CMD ["python3", "app.py"]