FROM python:3.10-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ libgl1-mesa-dev \ wget \ curl \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY app.py . # Copy static files (mini app) COPY static/ ./static/ # Create directories with proper permissions for all PaddleOCR models RUN mkdir -p /app/.paddlex \ /app/.paddleocr/whl/det/en/en_PP-OCRv3_det_infer \ /app/.paddleocr/whl/rec/en/en_PP-OCRv3_rec_infer \ /app/.paddleocr/whl/cls/en_ppocr_mobile_v2.0_cls_infer \ /app/temp && \ chmod -R 777 /app && \ chown -R 1000:1000 /app # Set environment variables ENV PYTHONPATH=/app ENV PADDLE_PDX_MODEL_SOURCE=BOS ENV PADDLE_HOME=/app/.paddlex ENV PADDLEX_HOME=/app/.paddlex ENV PADDLEOCR_HOME=/app/.paddleocr ENV TEMP=/app/temp ENV TMP=/app/temp ENV TMPDIR=/app/temp ENV HOME=/app ENV USER=app # Expose port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:7860/ || exit 1 # Run the application CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]