FROM python:3.12-slim AS runtime WORKDIR /app RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender1 \ libgomp1 \ poppler-utils \ && rm -rf /var/lib/apt/lists/* COPY requirements-prod.txt . RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu torch torchvision \ && pip install --no-cache-dir -r requirements-prod.txt RUN useradd -m -u 1000 -s /bin/bash appuser COPY --chown=appuser:appuser src/ ./src/ COPY --chown=appuser:appuser .streamlit/ ./.streamlit/ ENV HF_HOME=/data/huggingface \ HUGGINGFACE_HUB_CACHE=/data/huggingface/hub \ TRANSFORMERS_CACHE=/data/huggingface/hub \ HF_XET_HIGH_PERFORMANCE=1 \ LIGHTONOCR_MODEL_ID=PetaniHandal/LightOnOCR-2-1B-1025-ft-iam-handwriting-vllm \ CUDA_VISIBLE_DEVICES="" \ PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ STREAMLIT_SERVER_PORT=7860 \ STREAMLIT_SERVER_ADDRESS=0.0.0.0 \ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false EXPOSE 7860 USER appuser HEALTHCHECK --interval=30s --timeout=10s --start-period=180s --retries=3 \ CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/_stcore/health')" || exit 1 CMD ["python", "-m", "streamlit", "run", "src/app.py", \ "--server.port=7860", \ "--server.address=0.0.0.0", \ "--server.headless=true", \ "--server.enableXsrfProtection=false", \ "--server.maxUploadSize=20"]