File size: 758 Bytes
780fe32
 
 
1172cbd
780fe32
 
 
 
 
 
 
1172cbd
780fe32
1172cbd
 
 
780fe32
 
1172cbd
780fe32
 
 
1172cbd
 
780fe32
1172cbd
 
 
 
780fe32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Dockerfile
FROM python:3.10-slim

# Set up a non-root user for security and compatibility with HF Spaces
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
ENV HOME="/home/user"

WORKDIR /app

# Install system dependencies
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
    tesseract-ocr \
    && rm -rf /var/lib/apt/lists/*
USER user

# Copy and install Python packages
COPY --chown=user ./requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# Copy the application code
COPY --chown=user . .

# Expose the port required by HF Spaces
EXPOSE 7860

# Run the FastAPI application using Uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]