# Dockerfile | |
# Using the official Hugging Face template as a base | |
FROM python:3.10-slim | |
# Set up a non-root user for security | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
ENV HOME="/home/user" | |
WORKDIR /app | |
# Install system dependencies needed by our application (like Tesseract) | |
# We switch back to root temporarily to do this | |
USER root | |
RUN apt-get update && apt-get install -y tesseract-ocr && rm -rf /var/lib/apt/lists/* | |
# Switch back to the non-root user | |
USER user | |
# Copy requirements and install Python packages | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Copy the rest of the application code | |
COPY --chown=user . /app | |
# The command to run the application. Uvicorn will run our FastAPI app. | |
# The app itself will serve the Gradio UI. | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |