Spaces:
Running
Running
FROM python:3.10-slim | |
ENV PYTHONUNBUFFERED=1 | |
ENV TRANSFORMERS_CACHE=/app/cache | |
ENV UPLOAD_DIR=/app/uploads | |
ENV PORT=7860 | |
# Install system dependencies | |
RUN apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
gcc \ | |
python3-dev \ | |
libmagic1 \ | |
libmupdf-dev \ | |
poppler-utils \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create directories and set permissions | |
RUN mkdir -p /app/cache /app/uploads /app/static /app/images && \ | |
chmod -R 777 /app | |
WORKDIR /app | |
# Copy and install requirements | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -U pip setuptools wheel && \ | |
pip install --no-cache-dir -r requirements.txt | |
# Copy application code | |
COPY . . | |
# Expose port | |
EXPOSE 7860 | |
# Healthcheck | |
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | |
CMD curl -f http://localhost:7860/health || exit 1 | |
# Run the application | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |