# Use a minimal Python image | |
FROM python:3.10-slim | |
# Set environment variables for model caching | |
ENV HF_HOME=/tmp/hf_cache \ | |
TRANSFORMERS_CACHE=/tmp/hf_cache \ | |
PYTHONUNBUFFERED=1 | |
# System-level dependencies | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
poppler-utils \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Create app directory | |
WORKDIR /app | |
# Install Python dependencies | |
COPY requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the entire app | |
COPY . . | |
# Expose FastAPI port | |
EXPOSE 7860 | |
# Run the app | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |