# 1. Use a lightweight Python environment FROM python:3.10-slim # 2. Install TeX Live Full (Every package, modern fonts, everything) RUN apt-get update && apt-get install -y --no-install-recommends \ texlive-full \ biber \ && rm -rf /var/lib/apt/lists/* # 3. Create a non-root user (Required by Hugging Face Spaces) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # 4. Set up the working directory WORKDIR $HOME/app # 5. Copy and install Python requirements COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 6. Copy the server script COPY --chown=user latex-server.py . # 7. Expose the Hugging Face port (7860) and run with Gunicorn EXPOSE 7860 CMD ["gunicorn", "-w", "1", "-b", "0.0.0.0:7860", "--timeout", "300", "latex-server:app"]